diff options
| author | Jonas Schievink <jonasschievink@gmail.com> | 2020-06-15 20:54:40 +0200 |
|---|---|---|
| committer | Jonas Schievink <jonasschievink@gmail.com> | 2020-06-15 20:54:40 +0200 |
| commit | 4cb26ad7a3207ce48341d6a152b7212696bfdc0d (patch) | |
| tree | 94bd7ca63c7ccae9d8ced1d939c0d4141c43c34d | |
| parent | af97a117e538c5945cb19a4d3a045e509274d9cf (diff) | |
| download | rust-4cb26ad7a3207ce48341d6a152b7212696bfdc0d.tar.gz rust-4cb26ad7a3207ce48341d6a152b7212696bfdc0d.zip | |
Add test
| -rw-r--r-- | src/test/mir-opt/fn-ptr-shim.rs | 15 | ||||
| -rw-r--r-- | src/test/mir-opt/fn-ptr-shim/rustc.ops-function-Fn-call.AddMovesForPackedDrops.before.mir | 13 |
2 files changed, 28 insertions, 0 deletions
diff --git a/src/test/mir-opt/fn-ptr-shim.rs b/src/test/mir-opt/fn-ptr-shim.rs new file mode 100644 index 00000000000..08413c9f6fc --- /dev/null +++ b/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(); +} diff --git a/src/test/mir-opt/fn-ptr-shim/rustc.ops-function-Fn-call.AddMovesForPackedDrops.before.mir b/src/test/mir-opt/fn-ptr-shim/rustc.ops-function-Fn-call.AddMovesForPackedDrops.before.mir new file mode 100644 index 00000000000..4ecc331afae --- /dev/null +++ b/src/test/mir-opt/fn-ptr-shim/rustc.ops-function-Fn-call.AddMovesForPackedDrops.before.mir @@ -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 + } +} |
