6b24fdf811
``` error: unconstrained generic constant --> $DIR/const-argument-if-length.rs:18:10 | LL | pad: [u8; is_zst::<T>()], | ^^^^^^^^^^^^^^^^^^^ | help: try adding a `where` bound | LL | pub struct AtLeastByte<T: ?Sized> where [(); is_zst::<T>()]: { | ++++++++++++++++++++++++++ ``` Detect when the constant expression isn't `usize` and suggest casting: ``` error: unconstrained generic constant --> f300.rs:6:10 | 6 | bb::<{!N}>(); | ^^^^ -Ztrack-diagnostics: created at compiler/rustc_trait_selection/src/traits/error_reporting/type_err_ctxt_ext.rs:3539:36 | help: try adding a `where` bound | 5 | fn b<const N: bool>() where [(); {!N} as usize]: { | ++++++++++++++++++++++++++ ``` Fix #122395.
65 lines
1.5 KiB
Plaintext
65 lines
1.5 KiB
Plaintext
error: unconstrained generic constant
|
|
--> $DIR/issue-71202.rs:11:5
|
|
|
|
|
LL | / const ITEM_IS_COPY: [(); 1 - {
|
|
LL | | trait NotCopy {
|
|
LL | | const VALUE: bool = false;
|
|
LL | | }
|
|
... |
|
|
LL | | <IsCopy<T>>::VALUE
|
|
LL | | } as usize] = [];
|
|
| |_____________________^
|
|
|
|
|
help: try adding a `where` bound
|
|
|
|
|
LL ~ } as usize] where [(); 1 - {
|
|
LL + trait NotCopy {
|
|
LL + const VALUE: bool = false;
|
|
LL + }
|
|
LL +
|
|
LL + impl<__Type: ?Sized> NotCopy for __Type {}
|
|
LL +
|
|
LL + struct IsCopy<__Type: ?Sized>(PhantomData<__Type>);
|
|
LL +
|
|
LL + impl<__Type> IsCopy<__Type>
|
|
LL + where
|
|
LL + __Type: Sized + Copy,
|
|
LL + {
|
|
LL + const VALUE: bool = true;
|
|
LL + }
|
|
LL +
|
|
LL + <IsCopy<T>>::VALUE
|
|
LL ~ } as usize]: = [];
|
|
|
|
|
|
|
error: unconstrained generic constant
|
|
--> $DIR/issue-71202.rs:28:19
|
|
|
|
|
LL | } as usize] = [];
|
|
| ^^
|
|
|
|
|
help: try adding a `where` bound
|
|
|
|
|
LL ~ } as usize] where [(); 1 - {
|
|
LL + trait NotCopy {
|
|
LL + const VALUE: bool = false;
|
|
LL + }
|
|
LL +
|
|
LL + impl<__Type: ?Sized> NotCopy for __Type {}
|
|
LL +
|
|
LL + struct IsCopy<__Type: ?Sized>(PhantomData<__Type>);
|
|
LL +
|
|
LL + impl<__Type> IsCopy<__Type>
|
|
LL + where
|
|
LL + __Type: Sized + Copy,
|
|
LL + {
|
|
LL + const VALUE: bool = true;
|
|
LL + }
|
|
LL +
|
|
LL + <IsCopy<T>>::VALUE
|
|
LL ~ } as usize]: = [];
|
|
|
|
|
|
|
error: aborting due to 2 previous errors
|
|
|