about summary refs log tree commit diff
path: root/tests/mir-opt/gvn_uninhabited.rs
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2024-01-26 10:30:46 +0100
committerRalf Jung <post@ralfj.de>2024-01-26 10:40:29 +0100
commit64cd13ff3b9b5ca0ed88cd1cfd0d15aca846da7e (patch)
treee102ac0925b397275eed560e82f0042dc2d97995 /tests/mir-opt/gvn_uninhabited.rs
parent1025a12b64a7e5d852e02d59d86aca558733bed1 (diff)
downloadrust-64cd13ff3b9b5ca0ed88cd1cfd0d15aca846da7e.tar.gz
rust-64cd13ff3b9b5ca0ed88cd1cfd0d15aca846da7e.zip
add test for GVN issue; cleanup in dataflow_const_prop
Diffstat (limited to 'tests/mir-opt/gvn_uninhabited.rs')
-rw-r--r--tests/mir-opt/gvn_uninhabited.rs24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/mir-opt/gvn_uninhabited.rs b/tests/mir-opt/gvn_uninhabited.rs
new file mode 100644
index 00000000000..a55b2dd763a
--- /dev/null
+++ b/tests/mir-opt/gvn_uninhabited.rs
@@ -0,0 +1,24 @@
+// unit-test: GVN
+// compile-flags: -O
+// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
+// skip-filecheck
+
+#![feature(never_type)]
+
+#[derive(Copy, Clone)]
+pub enum E {
+    A(!, u32),
+}
+
+pub union U {
+    i: u32,
+    e: E,
+}
+
+// EMIT_MIR gvn_uninhabited.f.GVN.diff
+pub const fn f() -> u32 {
+    let E::A(_, i) = unsafe { (&U { i: 0 }).e };
+    i
+}
+
+fn main() {}