Skip to content

Commit 77fd0a7

Browse files
committed
add a mir-opt test that we don't add the spurious drop
1 parent 1962d75 commit 77fd0a7

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// ignore-wasm32-bare compiled with panic=abort by default
2+
3+
// Test that after the call to `std::mem::drop` we do not generate a
4+
// MIR drop of the argument. (We used to have a `DROP(_2)` in the code
5+
// below, as part of bb3.)
6+
7+
fn main() {
8+
std::mem::drop("".to_string());
9+
}
10+
11+
// END RUST SOURCE
12+
// START rustc.main.ElaborateDrops.before.mir
13+
// bb2: {
14+
// StorageDead(_3);
15+
// _1 = const std::mem::drop::<std::string::String>(move _2) -> [return: bb3, unwind: bb4];
16+
// }
17+
// bb3: {
18+
// StorageDead(_2);
19+
// StorageDead(_4);
20+
// StorageDead(_1);
21+
// _0 = ();
22+
// return;
23+
// }
24+
// END rustc.main.ElaborateDrops.before.mir

0 commit comments

Comments
 (0)