about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorNiko Matsakis <niko@alum.mit.edu>2019-09-19 16:12:48 -0400
committerNiko Matsakis <niko@alum.mit.edu>2019-09-19 16:12:48 -0400
commit77fd0a76491afb4c93359f6ceb33a9f79c4f4228 (patch)
tree4e2f24312acd299756018781b3dc7f039c098cbf /src
parent1962d75c10363e1754df5526ed8fa01d22e42f24 (diff)
downloadrust-77fd0a76491afb4c93359f6ceb33a9f79c4f4228.tar.gz
rust-77fd0a76491afb4c93359f6ceb33a9f79c4f4228.zip
add a mir-opt test that we don't add the spurious drop
Diffstat (limited to 'src')
-rw-r--r--src/test/mir-opt/no-spurious-drop-after-call.rs24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/test/mir-opt/no-spurious-drop-after-call.rs b/src/test/mir-opt/no-spurious-drop-after-call.rs
new file mode 100644
index 00000000000..782bc31186c
--- /dev/null
+++ b/src/test/mir-opt/no-spurious-drop-after-call.rs
@@ -0,0 +1,24 @@
+// ignore-wasm32-bare compiled with panic=abort by default
+
+// Test that after the call to `std::mem::drop` we do not generate a
+// MIR drop of the argument. (We used to have a `DROP(_2)` in the code
+// below, as part of bb3.)
+
+fn main() {
+    std::mem::drop("".to_string());
+}
+
+// END RUST SOURCE
+// START rustc.main.ElaborateDrops.before.mir
+//    bb2: {
+//        StorageDead(_3);
+//        _1 = const std::mem::drop::<std::string::String>(move _2) -> [return: bb3, unwind: bb4];
+//    }
+//    bb3: {
+//        StorageDead(_2);
+//        StorageDead(_4);
+//        StorageDead(_1);
+//        _0 = ();
+//        return;
+//    }
+// END rustc.main.ElaborateDrops.before.mir