We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 400b409 commit 2e9931fCopy full SHA for 2e9931f
src/test/run-pass/consts/const-enum-cast.rs
@@ -1,9 +1,8 @@
1
// run-pass
2
-#![allow(dead_code)]
3
#![allow(non_upper_case_globals)]
4
5
enum A { A1, A2 }
6
-enum B { B1=0, B2=2 }
+enum B { B1=4, B2=2 }
7
8
pub fn main () {
9
static c1: isize = A::A2 as isize;
@@ -14,4 +13,14 @@ pub fn main () {
14
13
assert_eq!(c2, 2);
15
assert_eq!(a1, 1);
16
assert_eq!(a2, 2);
+
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);
26
}
0 commit comments