File tree Expand file tree Collapse file tree 2 files changed +62
-0
lines changed
tests/ui/const-generics/mgca Expand file tree Collapse file tree 2 files changed +62
-0
lines changed Original file line number Diff line number Diff line change
1
+ #![ feature( generic_const_items, min_generic_const_args) ]
2
+ #![ expect( incomplete_features) ]
3
+
4
+ // Tests behaviour of attempting to evaluate const arguments whose wellformedness
5
+ // depends on impossible to satisfy predicates, that are satisfied from another
6
+ // trivially false clause in the environment.
7
+ //
8
+ // Additionally tests how (or if) this behaviour differs depending on whether the
9
+ // constants where trivially false where clause is global or not.
10
+
11
+ trait Unimplemented < ' a > { }
12
+
13
+ trait Trait {
14
+ const NON_GLOBAL <T >: usize
15
+ where
16
+ for <' a> T : Unimplemented <' a >;
17
+
18
+ const GLOBAL : usize
19
+ where
20
+ for <' a > ( ) : Unimplemented < ' a > ;
21
+ }
22
+
23
+ impl Trait for u8 {
24
+ const NON_GLOBAL <T >: usize = 1
25
+ where
26
+ for < ' a > T : Unimplemented < ' a > ;
27
+
28
+ const GLOBAL : usize = 1
29
+ //~^ ERROR: evaluation of constant value failed
30
+ where
31
+ for <' a > ( ) : Unimplemented < ' a > ;
32
+ }
33
+
34
+ struct Foo < const N : usize > ;
35
+
36
+ fn non_global ( )
37
+ where
38
+ for <' a > ( ) : Unimplemented < ' a > ,
39
+ {
40
+ let _: Foo < 1 > = Foo :: < { <u8 as Trait >:: NON_GLOBAL :: < ( ) > } > ;
41
+ }
42
+
43
+ fn global ( )
44
+ where
45
+ for < ' a > ( ) : Unimplemented < ' a > ,
46
+ {
47
+ let _: Foo < 1 > = Foo :: < { <u8 as Trait >:: GLOBAL } > ;
48
+ }
49
+
50
+ fn main ( ) { }
Original file line number Diff line number Diff line change
1
+ error[E0080]: evaluation of constant value failed
2
+ --> $DIR/impossible_preds_on_anon_const.rs:28:5
3
+ |
4
+ LL | / const GLOBAL: usize = 1
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