Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test more variants of enum-int-casting #61702

Merged
merged 1 commit into from
Jun 18, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions src/test/run-pass/consts/const-enum-cast.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
// run-pass
#![allow(dead_code)]
#![allow(non_upper_case_globals)]

enum A { A1, A2 }
enum B { B1=0, B2=2 }
enum B { B1=4, B2=2 }

pub fn main () {
static c1: isize = A::A2 as isize;
Expand All @@ -14,4 +13,14 @@ pub fn main () {
assert_eq!(c2, 2);
assert_eq!(a1, 1);
assert_eq!(a2, 2);

// Turns out that adding a let-binding generates totally different MIR.
static c1_2: isize = { let v = A::A1; v as isize };
static c2_2: isize = { let v = B::B1; v as isize };
let a1_2 = { let v = A::A1; v as isize };
let a2_2 = { let v = B::B1; v as isize };
assert_eq!(c1_2, 0);
assert_eq!(c2_2, 4);
assert_eq!(a1_2, 0);
assert_eq!(a2_2, 4);
}