summaryrefslogtreecommitdiffstats
path: root/tests/mir-opt/const_prop/address_of_pair.rs
blob: 730ebe2ca636bcfa0e43ace76cc587cd094b5cea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// unit-test: ConstProp

// EMIT_MIR address_of_pair.fn0.ConstProp.diff
pub fn fn0() -> bool {
    // CHECK-LABEL: fn fn0(
    // CHECK: debug pair => [[pair:_.*]];
    // CHECK: debug ptr => [[ptr:_.*]];
    // CHECK: debug ret => [[ret:_.*]];
    // CHECK: (*[[ptr]]) = const true;
    // CHECK-NOT: = const false;
    // CHECK-NOT: = const true;
    // CHECK: [[tmp:_.*]] = ([[pair]].1: bool);
    // CHECK-NOT: = const false;
    // CHECK-NOT: = const true;
    // CHECK: [[ret]] = Not(move [[tmp]]);
    // CHECK-NOT: = const false;
    // CHECK-NOT: = const true;
    // CHECK: _0 = [[ret]];
    let mut pair = (1, false);
    let ptr = core::ptr::addr_of_mut!(pair.1);
    pair = (1, false);
    unsafe {
        *ptr = true;
    }
    let ret = !pair.1;
    return ret;
}

pub fn main() {
    println!("{}", fn0());
}