]> git.proxmox.com Git - rustc.git/blobdiff - src/test/codegen/issue-73031.rs
Merge tag 'debian/1.52.1+dfsg1-1_exp2' into proxmox/buster
[rustc.git] / src / test / codegen / issue-73031.rs
diff --git a/src/test/codegen/issue-73031.rs b/src/test/codegen/issue-73031.rs
new file mode 100644 (file)
index 0000000..6ba4d70
--- /dev/null
@@ -0,0 +1,27 @@
+// min-llvm-version: 12.0.0
+// compile-flags: -O
+#![crate_type = "lib"]
+
+// Test that LLVM can eliminate the unreachable `All::None` branch.
+
+pub enum All {
+    None,
+    Foo,
+    Bar,
+}
+
+// CHECK-LABEL: @issue_73031
+#[no_mangle]
+pub fn issue_73031(a: &mut All, q: i32) -> i32 {
+    *a = if q == 5 {
+        All::Foo
+    } else {
+        All::Bar
+    };
+    match *a {
+        // CHECK-NOT: panic
+        All::None => panic!(),
+        All::Foo => 1,
+        All::Bar => 2,
+    }
+}