Skip to content

Commit 2e9931f

Browse files
committed
test more variants of enum-int-casting
1 parent 400b409 commit 2e9931f

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/test/run-pass/consts/const-enum-cast.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
// run-pass
2-
#![allow(dead_code)]
32
#![allow(non_upper_case_globals)]
43

54
enum A { A1, A2 }
6-
enum B { B1=0, B2=2 }
5+
enum B { B1=4, B2=2 }
76

87
pub fn main () {
98
static c1: isize = A::A2 as isize;
@@ -14,4 +13,14 @@ pub fn main () {
1413
assert_eq!(c2, 2);
1514
assert_eq!(a1, 1);
1615
assert_eq!(a2, 2);
16+
17+
// Turns out that adding a let-binding generates totally different MIR.
18+
static c1_2: isize = { let v = A::A1; v as isize };
19+
static c2_2: isize = { let v = B::B1; v as isize };
20+
let a1_2 = { let v = A::A1; v as isize };
21+
let a2_2 = { let v = B::B1; v as isize };
22+
assert_eq!(c1_2, 0);
23+
assert_eq!(c2_2, 4);
24+
assert_eq!(a1_2, 0);
25+
assert_eq!(a2_2, 4);
1726
}

0 commit comments

Comments
 (0)