2023-10-16 12:36:39 -05:00
|
|
|
// skip-filecheck
|
2023-06-08 02:18:34 -05:00
|
|
|
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
|
2023-02-04 05:48:28 -06:00
|
|
|
//@ 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);
|
|
|
|
|
2023-12-31 18:00:00 -06:00
|
|
|
#[custom_mir(dialect = "runtime")]
|
2023-02-04 05:48:28 -06:00
|
|
|
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);
|
2023-12-31 18:00:00 -06:00
|
|
|
Call(RET = opaque(Move(a)), ReturnTo(bb1), UnwindUnreachable())
|
2023-02-04 05:48:28 -06:00
|
|
|
}
|
|
|
|
bb1 = {
|
2023-12-31 18:00:00 -06:00
|
|
|
Call(RET = opaque(Move(c)), ReturnTo(ret), UnwindUnreachable())
|
2023-02-04 05:48:28 -06:00
|
|
|
}
|
|
|
|
ret = {
|
|
|
|
Return()
|
|
|
|
}
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
assert!(f(Foo(0)));
|
|
|
|
}
|
|
|
|
|
|
|
|
// EMIT_MIR move_projection.f.CopyProp.diff
|