Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed Jul 6, 2022
1 parent 8f867c5 commit 2a1a718
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/test/ui/consts/const-enum-cast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,19 @@
enum A { A1, A2 }
enum B { B1=4, B2=2 }

#[allow(dead_code)]
#[repr(align(8))]
enum Aligned {
Zero = 0,
One = 1,
}

// regression test for https://github.com/rust-lang/rust/issues/96185
const X: u8 = {
let aligned = Aligned::Zero;
aligned as u8
};

pub fn main () {
static c1: isize = A::A2 as isize;
static c2: isize = B::B2 as isize;
Expand All @@ -23,4 +36,6 @@ pub fn main () {
assert_eq!(c2_2, 4);
assert_eq!(a1_2, 0);
assert_eq!(a2_2, 4);

assert_eq!(X, 0);
}

0 comments on commit 2a1a718

Please sign in to comment.