Skip to content

Commit

Permalink
add a mir-opt test that we don't add the spurious drop
Browse files Browse the repository at this point in the history
  • Loading branch information
nikomatsakis committed Sep 19, 2019
1 parent 1962d75 commit 77fd0a7
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions 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

0 comments on commit 77fd0a7

Please sign in to comment.