Wfness
This commit is contained in:
parent
a81e489101
commit
83a1834c14
2 changed files with 59 additions and 0 deletions
21
src/test/ui/const-generics/defaults/wfness.rs
Normal file
21
src/test/ui/const-generics/defaults/wfness.rs
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
#![feature(const_generics_defaults)]
|
||||
|
||||
struct Ooopsies<const N: u8 = { u8::MAX + 1 }>;
|
||||
//~^ error: evaluation of constant value failed
|
||||
|
||||
trait Trait<const N: u8> {}
|
||||
impl Trait<3> for () {}
|
||||
struct WhereClause<const N: u8 = 2> where (): Trait<N>;
|
||||
//~^ error: the trait bound `(): Trait<2_u8>` is not satisfied
|
||||
|
||||
trait Traitor<T, const N: u8> {}
|
||||
struct WhereClauseTooGeneric<T = u32, const N: u8 = 2>(T) where (): Traitor<T, N>;
|
||||
|
||||
// no error on struct def
|
||||
struct DependentDefaultWfness<const N: u8 = 1, T = WhereClause<N>>(T);
|
||||
fn foo() -> DependentDefaultWfness {
|
||||
//~^ error: the trait bound `(): Trait<1_u8>` is not satisfied
|
||||
loop {}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
38
src/test/ui/const-generics/defaults/wfness.stderr
Normal file
38
src/test/ui/const-generics/defaults/wfness.stderr
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/wfness.rs:3:33
|
||||
|
|
||||
LL | struct Ooopsies<const N: u8 = { u8::MAX + 1 }>;
|
||||
| ^^^^^^^^^^^ attempt to compute `u8::MAX + 1_u8`, which would overflow
|
||||
|
||||
error[E0277]: the trait bound `(): Trait<2_u8>` is not satisfied
|
||||
--> $DIR/wfness.rs:8:47
|
||||
|
|
||||
LL | struct WhereClause<const N: u8 = 2> where (): Trait<N>;
|
||||
| ^^^^^^^^ the trait `Trait<2_u8>` is not implemented for `()`
|
||||
|
|
||||
= help: the following implementations were found:
|
||||
<() as Trait<3_u8>>
|
||||
note: required by `WhereClause`
|
||||
--> $DIR/wfness.rs:8:1
|
||||
|
|
||||
LL | struct WhereClause<const N: u8 = 2> where (): Trait<N>;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0277]: the trait bound `(): Trait<1_u8>` is not satisfied
|
||||
--> $DIR/wfness.rs:16:13
|
||||
|
|
||||
LL | fn foo() -> DependentDefaultWfness {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^ the trait `Trait<1_u8>` is not implemented for `()`
|
||||
|
|
||||
= help: the following implementations were found:
|
||||
<() as Trait<3_u8>>
|
||||
note: required by a bound in `WhereClause`
|
||||
--> $DIR/wfness.rs:8:47
|
||||
|
|
||||
LL | struct WhereClause<const N: u8 = 2> where (): Trait<N>;
|
||||
| ^^^^^^^^ required by this bound in `WhereClause`
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0080, E0277.
|
||||
For more information about an error, try `rustc --explain E0080`.
|
||||
Loading…
Add table
Add a link
Reference in a new issue