File tree 2 files changed +36
-0
lines changed
src/test/ui/type-alias-enum-variants
2 files changed +36
-0
lines changed Original file line number Diff line number Diff line change
1
+ #[ repr( u8 ) ]
2
+ enum Alpha {
3
+ V1 = 41 ,
4
+ V2 = Self :: V1 as u8 + 1 , // OK -- but why?
5
+ V3 = Self :: V1 { } as u8 + 2 , //~ ERROR cycle detected when const-evaluating
6
+ }
7
+
8
+ fn main ( ) { }
Original file line number Diff line number Diff line change
1
+ error[E0391]: cycle detected when const-evaluating + checking `Alpha::V3::{{constant}}#0`
2
+ --> $DIR/self-in-enum-definition.rs:5:10
3
+ |
4
+ LL | V3 = Self::V1 {} as u8 + 2,
5
+ | ^^^^^^^^
6
+ |
7
+ note: ...which requires const-evaluating `Alpha::V3::{{constant}}#0`...
8
+ --> $DIR/self-in-enum-definition.rs:5:10
9
+ |
10
+ LL | V3 = Self::V1 {} as u8 + 2,
11
+ | ^^^^^^^^
12
+ = note: ...which requires computing layout of `Alpha`...
13
+ = note: ...which again requires const-evaluating + checking `Alpha::V3::{{constant}}#0`, completing the cycle
14
+ note: cycle used when collecting item types in top-level module
15
+ --> $DIR/self-in-enum-definition.rs:1:1
16
+ |
17
+ LL | / #[repr(u8)]
18
+ LL | | enum Alpha {
19
+ LL | | V1 = 41,
20
+ LL | | V2 = Self::V1 as u8 + 1, // OK -- but why?
21
+ ... |
22
+ LL | |
23
+ LL | | fn main() {}
24
+ | |____________^
25
+
26
+ error: aborting due to previous error
27
+
28
+ For more information about this error, try `rustc --explain E0391`.
You can’t perform that action at this time.
0 commit comments