File tree Expand file tree Collapse file tree 2 files changed +70
-0
lines changed Expand file tree Collapse file tree 2 files changed +70
-0
lines changed Original file line number Diff line number Diff line change 1+ #![ feature( generic_const_items) ]
2+ #![ expect( incomplete_features) ]
3+
4+ trait Unimplemented < ' a > { }
5+
6+ trait Trait < T >
7+ where
8+ for < ' a > T : Unimplemented < ' a > ,
9+ {
10+ const ASSOC : usize ;
11+ }
12+
13+ impl < T > Trait < T > for ( )
14+ where
15+ for < ' a > T : Unimplemented < ' a > ,
16+ {
17+ const ASSOC : usize = 0 ;
18+ }
19+
20+ trait Global {
21+ const ASSOC : usize
22+ where
23+ for <' a > ( ) : Unimplemented < ' a > ;
24+ }
25+
26+ impl Global for ( ) {
27+ const ASSOC : usize = 0
28+ //~^ ERROR: evaluation of constant value failed
29+ where
30+ for <' a > ( ) : Unimplemented < ' a > ;
31+ }
32+
33+ fn works ( x : usize )
34+ where
35+ for <' a > ( ) : Unimplemented < ' a > ,
36+ {
37+ // In order for match exhaustiveness to determine this match is OK, CTFE must
38+ // be able to evalaute `<() as Trait>::ASSOC` which depends on a trivially
39+ // false bound for well formedness.
40+ match x {
41+ <( ) as Trait < ( ) > >:: ASSOC => todo ! ( ) ,
42+ 1 .. => todo ! ( ) ,
43+ }
44+ }
45+
46+ fn errors ( x : usize )
47+ where
48+ for < ' a > ( ) : Unimplemented < ' a > ,
49+ {
50+ // This errors due to the MIR for `ASSOC` being empty due to the
51+ // globally false bound.
52+ match x {
53+ <( ) as Global >:: ASSOC => todo ! ( ) ,
54+ 1 .. => todo ! ( ) ,
55+ }
56+ }
57+
58+ fn main ( ) { }
Original file line number Diff line number Diff line change 1+ error[E0080]: evaluation of constant value failed
2+ --> $DIR/impossible_preds_const_pattern.rs:27:5
3+ |
4+ LL | / const ASSOC: usize = 0
5+ LL | |
6+ LL | | where
7+ LL | | for<'a> (): Unimplemented<'a>;
8+ | |______________________________________^ entering unreachable code
9+
10+ error: aborting due to 1 previous error
11+
12+ For more information about this error, try `rustc --explain E0080`.
You can’t perform that action at this time.
0 commit comments