Skip to content

Commit 2a1a718

Browse files
committed
add test
1 parent 8f867c5 commit 2a1a718

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/test/ui/consts/const-enum-cast.rs

+15
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,19 @@
44
enum A { A1, A2 }
55
enum B { B1=4, B2=2 }
66

7+
#[allow(dead_code)]
8+
#[repr(align(8))]
9+
enum Aligned {
10+
Zero = 0,
11+
One = 1,
12+
}
13+
14+
// regression test for https://github.com/rust-lang/rust/issues/96185
15+
const X: u8 = {
16+
let aligned = Aligned::Zero;
17+
aligned as u8
18+
};
19+
720
pub fn main () {
821
static c1: isize = A::A2 as isize;
922
static c2: isize = B::B2 as isize;
@@ -23,4 +36,6 @@ pub fn main () {
2336
assert_eq!(c2_2, 4);
2437
assert_eq!(a1_2, 0);
2538
assert_eq!(a2_2, 4);
39+
40+
assert_eq!(X, 0);
2641
}

0 commit comments

Comments
 (0)