Skip to content

Commit 83a1834

Browse files
committed
Wfness
1 parent a81e489 commit 83a1834

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#![feature(const_generics_defaults)]
2+
3+
struct Ooopsies<const N: u8 = { u8::MAX + 1 }>;
4+
//~^ error: evaluation of constant value failed
5+
6+
trait Trait<const N: u8> {}
7+
impl Trait<3> for () {}
8+
struct WhereClause<const N: u8 = 2> where (): Trait<N>;
9+
//~^ error: the trait bound `(): Trait<2_u8>` is not satisfied
10+
11+
trait Traitor<T, const N: u8> {}
12+
struct WhereClauseTooGeneric<T = u32, const N: u8 = 2>(T) where (): Traitor<T, N>;
13+
14+
// no error on struct def
15+
struct DependentDefaultWfness<const N: u8 = 1, T = WhereClause<N>>(T);
16+
fn foo() -> DependentDefaultWfness {
17+
//~^ error: the trait bound `(): Trait<1_u8>` is not satisfied
18+
loop {}
19+
}
20+
21+
fn main() {}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
error[E0080]: evaluation of constant value failed
2+
--> $DIR/wfness.rs:3:33
3+
|
4+
LL | struct Ooopsies<const N: u8 = { u8::MAX + 1 }>;
5+
| ^^^^^^^^^^^ attempt to compute `u8::MAX + 1_u8`, which would overflow
6+
7+
error[E0277]: the trait bound `(): Trait<2_u8>` is not satisfied
8+
--> $DIR/wfness.rs:8:47
9+
|
10+
LL | struct WhereClause<const N: u8 = 2> where (): Trait<N>;
11+
| ^^^^^^^^ the trait `Trait<2_u8>` is not implemented for `()`
12+
|
13+
= help: the following implementations were found:
14+
<() as Trait<3_u8>>
15+
note: required by `WhereClause`
16+
--> $DIR/wfness.rs:8:1
17+
|
18+
LL | struct WhereClause<const N: u8 = 2> where (): Trait<N>;
19+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
20+
21+
error[E0277]: the trait bound `(): Trait<1_u8>` is not satisfied
22+
--> $DIR/wfness.rs:16:13
23+
|
24+
LL | fn foo() -> DependentDefaultWfness {
25+
| ^^^^^^^^^^^^^^^^^^^^^^ the trait `Trait<1_u8>` is not implemented for `()`
26+
|
27+
= help: the following implementations were found:
28+
<() as Trait<3_u8>>
29+
note: required by a bound in `WhereClause`
30+
--> $DIR/wfness.rs:8:47
31+
|
32+
LL | struct WhereClause<const N: u8 = 2> where (): Trait<N>;
33+
| ^^^^^^^^ required by this bound in `WhereClause`
34+
35+
error: aborting due to 3 previous errors
36+
37+
Some errors have detailed explanations: E0080, E0277.
38+
For more information about an error, try `rustc --explain E0080`.

0 commit comments

Comments
 (0)