Skip to content

Commit 7d0ba2d

Browse files
committed
Add a mir-opt test for dropping parameters
1 parent 1d68e6d commit 7d0ba2d

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
- // MIR for `drop_both_arguments` before Inline
2+
+ // MIR for `drop_both_arguments` after Inline
3+
4+
fn drop_both_arguments(_1: CallThingOnDrop, _2: CallThingOnDrop) -> () {
5+
debug _a => _1;
6+
debug _b => _2;
7+
let mut _0: ();
8+
9+
bb0: {
10+
_0 = const ();
11+
drop(_2) -> [return: bb1, unwind: bb3];
12+
}
13+
14+
bb1: {
15+
drop(_1) -> [return: bb2, unwind: bb4];
16+
}
17+
18+
bb2: {
19+
return;
20+
}
21+
22+
bb3 (cleanup): {
23+
drop(_1) -> [return: bb4, unwind terminate(cleanup)];
24+
}
25+
26+
bb4 (cleanup): {
27+
resume;
28+
}
29+
}
30+

tests/mir-opt/inline/inline_drop.rs

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Test for inlining with an indirect destination place.
2+
//
3+
//@ test-mir-pass: Inline
4+
//@ edition: 2021
5+
//@ needs-unwind
6+
#![crate_type = "lib"]
7+
8+
#[inline(never)]
9+
fn thing() {}
10+
11+
struct CallThingOnDrop;
12+
13+
impl Drop for CallThingOnDrop {
14+
#[inline]
15+
fn drop(&mut self) {
16+
thing();
17+
}
18+
}
19+
20+
// EMIT_MIR inline_drop.drop_both_arguments.Inline.diff
21+
pub fn drop_both_arguments(_a: CallThingOnDrop, _b: CallThingOnDrop) {
22+
// CHECK: drop(_2)
23+
// CHECK: drop(_1)
24+
}

0 commit comments

Comments
 (0)