summary refs log tree commit diff
path: root/src/test/mir-opt/while-storage.rs
blob: a486bd49a77d00401ac550f8e16409939aaefcfa (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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// Test that we correctly generate StorageDead statements for while loop
// conditions on all branches

fn get_bool(c: bool) -> bool {
    c
}

fn while_loop(c: bool) {
    while get_bool(c) {
        if get_bool(c) {
            break;
        }
    }
}

fn main() {
    while_loop(false);
}

// END RUST SOURCE

// START rustc.while_loop.PreCodegen.after.mir
// bb0: {
//     StorageLive(_2);
//     StorageLive(_3);
//     _3 = _1;
//     _2 = const get_bool(move _3) -> bb2;
// }
// bb1: {
//     return;
// }
// bb2: {
//     StorageDead(_3);
//     switchInt(move _2) -> [false: bb4, otherwise: bb3];
// }
// bb3: {
//     StorageDead(_2);
//     StorageLive(_4);
//     StorageLive(_5);
//     _5 = _1;
//     _4 = const get_bool(move _5) -> bb5;
// }
// bb4: {
//     StorageDead(_2);
//     goto -> bb1;
// }
// bb5: {
//     StorageDead(_5);
//     switchInt(_4) -> [false: bb6, otherwise: bb7];
// }
// bb6: {
//     StorageDead(_4);
//     goto -> bb0;
// }
// bb7: {
//     StorageDead(_4);
//     goto -> bb1;
// }
// END rustc.while_loop.PreCodegen.after.mir