diff options
| author | Ellen <supbscripter@gmail.com> | 2021-10-20 23:31:08 +0100 |
|---|---|---|
| committer | Ellen <supbscripter@gmail.com> | 2021-10-20 23:31:08 +0100 |
| commit | 83a1834c14cbdd526f48f496d19a430b9f53ae38 (patch) | |
| tree | 553102e60a60d8f2d7fd26f715c81e20d1fe0fca | |
| parent | a81e4891017efed225318493f490f53e5c5111e7 (diff) | |
| download | rust-83a1834c14cbdd526f48f496d19a430b9f53ae38.tar.gz rust-83a1834c14cbdd526f48f496d19a430b9f53ae38.zip | |
Wfness
| -rw-r--r-- | src/test/ui/const-generics/defaults/wfness.rs | 21 | ||||
| -rw-r--r-- | src/test/ui/const-generics/defaults/wfness.stderr | 38 |
2 files changed, 59 insertions, 0 deletions
diff --git a/src/test/ui/const-generics/defaults/wfness.rs b/src/test/ui/const-generics/defaults/wfness.rs new file mode 100644 index 00000000000..d2b53eaf929 --- /dev/null +++ b/src/test/ui/const-generics/defaults/wfness.rs @@ -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() {} diff --git a/src/test/ui/const-generics/defaults/wfness.stderr b/src/test/ui/const-generics/defaults/wfness.stderr new file mode 100644 index 00000000000..9826af8802a --- /dev/null +++ b/src/test/ui/const-generics/defaults/wfness.stderr @@ -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`. |
