Skip to content

Commit 2e193f7

Browse files
committed
Add test self-in-enum-definition
1 parent 299ef86 commit 2e193f7

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
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 numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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`.

0 commit comments

Comments
 (0)