Skip to content

Commit 2fd4c28

Browse files
Negative test for inlining <Box<dyn Fn()> as Fn<()>>::call
1 parent fcf3006 commit 2fd4c28

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
- // MIR for `call` before Inline
2+
+ // MIR for `call` after Inline
3+
4+
fn call(_1: Box<dyn Fn(i32)>) -> () {
5+
debug x => _1;
6+
let mut _0: ();
7+
let _2: ();
8+
let mut _3: &std::boxed::Box<dyn std::ops::Fn(i32)>;
9+
let mut _4: (i32,);
10+
11+
bb0: {
12+
StorageLive(_2);
13+
StorageLive(_3);
14+
_3 = &_1;
15+
StorageLive(_4);
16+
_4 = (const 1_i32,);
17+
_2 = <Box<dyn Fn(i32)> as Fn<(i32,)>>::call(move _3, move _4) -> [return: bb1, unwind unreachable];
18+
}
19+
20+
bb1: {
21+
StorageDead(_4);
22+
StorageDead(_3);
23+
StorageDead(_2);
24+
_0 = const ();
25+
drop(_1) -> [return: bb2, unwind unreachable];
26+
}
27+
28+
bb2: {
29+
return;
30+
}
31+
}
32+

tests/mir-opt/inline/inline_box_fn.rs

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// unit-test: Inline
2+
// compile-flags: --crate-type=lib
3+
4+
// EMIT_MIR inline_box_fn.call.Inline.diff
5+
fn call(x: Box<dyn Fn(i32)>) {
6+
x(1);
7+
}

0 commit comments

Comments
 (0)