summaryrefslogtreecommitdiffstats
path: root/src/test/mir-opt/dest-prop/branch.rs
blob: fffcf82b3f1d8f32d087bdc7b75ee2f60dc3efd3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
//! Tests that assignment in both branches of an `if` are eliminated.
// compile-flags: -Zunsound-mir-opts
fn val() -> i32 {
    1
}

fn cond() -> bool {
    true
}

// EMIT_MIR branch.main.DestinationPropagation.diff
fn main() {
    let x = val();

    let y = if cond() {
        x
    } else {
        val();
        x
    };
}