Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
jonas-schievink committed Jun 15, 2020
1 parent af97a11 commit 4cb26ad
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/test/mir-opt/fn-ptr-shim.rs
@@ -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
}
}

0 comments on commit 4cb26ad

Please sign in to comment.