Rollup merge of #73359 - jonas-schievink:do-the-shimmy, r=matthewjasper
shim.rs: avoid creating `Call` terminators calling `Self` Also contains some cleanup and doc comment additions so I could make sense of the code. Fixes https://github.com/rust-lang/rust/issues/73109 Closes https://github.com/rust-lang/rust/pull/73175 r? @matthewjasper
This commit is contained in:
commit
fe4b4858ca
6 changed files with 123 additions and 33 deletions
15
src/test/mir-opt/fn-ptr-shim.rs
Normal file
15
src/test/mir-opt/fn-ptr-shim.rs
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
// compile-flags: -Zmir-opt-level=0 -Zvalidate-mir
|
||||
|
||||
// Tests that the `<fn() as Fn>` shim does not create a `Call` terminator with a `Self` callee
|
||||
// (as only `FnDef` and `FnPtr` callees are allowed in MIR).
|
||||
|
||||
// EMIT_MIR rustc.ops-function-Fn-call.AddMovesForPackedDrops.before.mir
|
||||
fn main() {
|
||||
call(noop as fn());
|
||||
}
|
||||
|
||||
fn noop() {}
|
||||
|
||||
fn call<F: Fn()>(f: F) {
|
||||
f();
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
// MIR for `std::ops::Fn::call` before AddMovesForPackedDrops
|
||||
|
||||
fn std::ops::Fn::call(_1: *const fn(), _2: Args) -> <Self as std::ops::FnOnce<Args>>::Output {
|
||||
let mut _0: <Self as std::ops::FnOnce<Args>>::Output; // return place in scope 0 at $SRC_DIR/libcore/ops/function.rs:LL:COL
|
||||
|
||||
bb0: {
|
||||
_0 = move (*_1)() -> bb1; // scope 0 at $SRC_DIR/libcore/ops/function.rs:LL:COL
|
||||
}
|
||||
|
||||
bb1: {
|
||||
return; // scope 0 at $SRC_DIR/libcore/ops/function.rs:LL:COL
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue