78da577650
Cleanup blocks are declared with `bb (cleanup) = { ... }`. `Call` and `Drop` terminators take an additional argument describing the unwind action, which is one of the following: * `UnwindContinue()` * `UnwindUnreachable()` * `UnwindTerminate(reason)`, where reason is `ReasonAbi` or `ReasonInCleanup` * `UnwindCleanup(block)` Also support unwind resume and unwind terminate terminators: * `UnwindResume()` * `UnwindTerminate(reason)`
37 lines
794 B
Rust
37 lines
794 B
Rust
// skip-filecheck
|
|
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
|
|
// unit-test: CopyProp
|
|
|
|
#![feature(custom_mir, core_intrinsics)]
|
|
#![allow(unused_assignments)]
|
|
extern crate core;
|
|
use core::intrinsics::mir::*;
|
|
|
|
fn opaque(_: impl Sized) -> bool { true }
|
|
|
|
struct Foo(u8);
|
|
|
|
#[custom_mir(dialect = "analysis", phase = "post-cleanup")]
|
|
fn f(a: Foo) -> bool {
|
|
mir!(
|
|
{
|
|
let b = a;
|
|
// This is a move out of a copy, so must become a copy of `a.0`.
|
|
let c = Move(b.0);
|
|
Call(RET = opaque(Move(a)), bb1, UnwindContinue())
|
|
}
|
|
bb1 = {
|
|
Call(RET = opaque(Move(c)), ret, UnwindContinue())
|
|
}
|
|
ret = {
|
|
Return()
|
|
}
|
|
)
|
|
}
|
|
|
|
fn main() {
|
|
assert!(f(Foo(0)));
|
|
}
|
|
|
|
// EMIT_MIR move_projection.f.CopyProp.diff
|