summary refs log tree commit diff
path: root/tests/mir-opt/const_prop/pointer_expose_address.rs
blob: 8944232f71ee4b6d3d89a09732a12714641544d8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
// unit-test: GVN

#[inline(never)]
fn read(_: usize) { }

// EMIT_MIR pointer_expose_address.main.GVN.diff
fn main() {
    // CHECK-LABEL: fn main(
    // CHECK: [[ptr:_.*]] = const _;
    // CHECK: [[ref:_.*]] = &raw const (*[[ptr]]);
    // CHECK: [[x:_.*]] = move [[ref]] as usize (PointerExposeAddress);
    // CHECK: = read([[x]])
    const FOO: &i32 = &1;
    let x = FOO as *const i32 as usize;
    read(x);
}