about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'src/test')
-rw-r--r--src/test/mir-opt/remove_zsts_dont_touch_unions.get_union.RemoveZsts.after.mir13
-rw-r--r--src/test/mir-opt/remove_zsts_dont_touch_unions.rs19
2 files changed, 32 insertions, 0 deletions
diff --git a/src/test/mir-opt/remove_zsts_dont_touch_unions.get_union.RemoveZsts.after.mir b/src/test/mir-opt/remove_zsts_dont_touch_unions.get_union.RemoveZsts.after.mir
new file mode 100644
index 00000000000..33bd9eb9b19
--- /dev/null
+++ b/src/test/mir-opt/remove_zsts_dont_touch_unions.get_union.RemoveZsts.after.mir
@@ -0,0 +1,13 @@
+// MIR for `get_union` after RemoveZsts
+
+fn get_union() -> Foo {
+    let mut _0: Foo;                     // return place in scope 0 at $DIR/remove_zsts_dont_touch_unions.rs:12:19: 12:22
+    let mut _1: ();                      // in scope 0 at $DIR/remove_zsts_dont_touch_unions.rs:13:14: 13:16
+
+    bb0: {
+        StorageLive(_1);                 // scope 0 at $DIR/remove_zsts_dont_touch_unions.rs:13:14: 13:16
+        (_0.0: ()) = move _1;            // scope 0 at $DIR/remove_zsts_dont_touch_unions.rs:13:5: 13:18
+        StorageDead(_1);                 // scope 0 at $DIR/remove_zsts_dont_touch_unions.rs:13:17: 13:18
+        return;                          // scope 0 at $DIR/remove_zsts_dont_touch_unions.rs:14:2: 14:2
+    }
+}
diff --git a/src/test/mir-opt/remove_zsts_dont_touch_unions.rs b/src/test/mir-opt/remove_zsts_dont_touch_unions.rs
new file mode 100644
index 00000000000..7a6f86b8085
--- /dev/null
+++ b/src/test/mir-opt/remove_zsts_dont_touch_unions.rs
@@ -0,0 +1,19 @@
+// compile-flags: -Zmir-opt-level=3
+
+// Ensure RemoveZsts doesn't remove ZST assignments to union fields,
+// which causes problems in Miri.
+
+union Foo {
+    x: (),
+    y: u64,
+}
+
+// EMIT_MIR remove_zsts_dont_touch_unions.get_union.RemoveZsts.after.mir
+fn get_union() -> Foo {
+    Foo { x: () }
+}
+
+
+fn main() {
+    get_union();
+}