]> git.lizzy.rs Git - rust.git/blob - src/test/mir-opt/while-storage.rs
Rollup merge of #69287 - GuillaumeGomez:clean-e0317, r=Dylan-DPC
[rust.git] / src / test / mir-opt / while-storage.rs
1 // Test that we correctly generate StorageDead statements for while loop
2 // conditions on all branches
3
4 fn get_bool(c: bool) -> bool {
5     c
6 }
7
8 fn while_loop(c: bool) {
9     while get_bool(c) {
10         if get_bool(c) {
11             break;
12         }
13     }
14 }
15
16 fn main() {
17     while_loop(false);
18 }
19
20 // END RUST SOURCE
21
22 // START rustc.while_loop.PreCodegen.after.mir
23 // bb0: {
24 //     StorageLive(_2);
25 //     StorageLive(_3);
26 //     _3 = _1;
27 //     _2 = const get_bool(move _3) -> bb1;
28 // }
29 // bb1: {
30 //     StorageDead(_3);
31 //     switchInt(_2) -> [false: bb6, otherwise: bb2];
32 // }
33 // bb2: {
34 //      StorageLive(_4);
35 //      StorageLive(_5);
36 //      _5 = _1;
37 //      _4 = const get_bool(move _5) -> bb3;
38 // }
39 // bb3: {
40 //      StorageDead(_5);
41 //      switchInt(_4) -> [false: bb4, otherwise: bb5];
42 // }
43 // bb4: {
44 //      StorageDead(_4);
45 //      StorageDead(_2);
46 //      goto -> bb0;
47 // }
48 //  bb5: {
49 //      StorageDead(_4);
50 //      goto -> bb6;
51 //  }
52 //  bb6: {
53 //      StorageDead(_2);
54 //      return;
55 //  }
56 // END rustc.while_loop.PreCodegen.after.mir