2023-06-08 02:18:34 -05:00
|
|
|
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
|
2023-01-20 13:34:46 -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 }
|
|
|
|
|
|
|
|
fn cmp_ref(a: &u8, b: &u8) -> bool {
|
|
|
|
std::ptr::eq(a as *const u8, b as *const u8)
|
|
|
|
}
|
|
|
|
|
|
|
|
#[custom_mir(dialect = "analysis", phase = "post-cleanup")]
|
|
|
|
fn f() -> bool {
|
|
|
|
mir!(
|
|
|
|
{
|
|
|
|
let a = 5_u8;
|
|
|
|
let r1 = &a;
|
|
|
|
let b = a;
|
|
|
|
// We cannot propagate the place `a`.
|
|
|
|
let r2 = &b;
|
2023-08-19 11:08:23 -05:00
|
|
|
Call(RET = cmp_ref(r1, r2), next)
|
2023-01-20 13:34:46 -06:00
|
|
|
}
|
|
|
|
next = {
|
|
|
|
// But we can propagate the value `a`.
|
2023-08-19 11:08:23 -05:00
|
|
|
Call(RET = opaque(b), ret)
|
2023-01-20 13:34:46 -06:00
|
|
|
}
|
|
|
|
ret = {
|
|
|
|
Return()
|
|
|
|
}
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
assert!(!f());
|
|
|
|
}
|
|
|
|
|
|
|
|
// EMIT_MIR borrowed_local.f.CopyProp.diff
|