about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2022-07-05 20:29:37 -0400
committerRalf Jung <post@ralfj.de>2022-07-05 22:26:26 -0400
commit2a1a718baabcc1fac08ed9a6ac3e29d5b156c532 (patch)
tree064839b667dfe687a0f895ce3b3abfed638d26c8
parent8f867c5445f22fcb119b46219fecc886d4f124b2 (diff)
downloadrust-2a1a718baabcc1fac08ed9a6ac3e29d5b156c532.tar.gz
rust-2a1a718baabcc1fac08ed9a6ac3e29d5b156c532.zip
add test
-rw-r--r--src/test/ui/consts/const-enum-cast.rs15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/test/ui/consts/const-enum-cast.rs b/src/test/ui/consts/const-enum-cast.rs
index a3255c2f601..39968495144 100644
--- a/src/test/ui/consts/const-enum-cast.rs
+++ b/src/test/ui/consts/const-enum-cast.rs
@@ -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;
@@ -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);
 }