]> git.lizzy.rs Git - rust.git/blob - src/test/mir-opt/loop_test.rs
34891ee70b5c6c3d45f07e7a61be8003dac03cd4
[rust.git] / src / test / mir-opt / loop_test.rs
1 // compile-flags: -Z identify_regions
2
3 // Tests to make sure we correctly generate falseUnwind edges in loops
4
5 fn main() {
6     // Exit early at runtime. Since only care about the generated MIR
7     // and not the runtime behavior (which is exercised by other tests)
8     // we just bail early. Without this the test just loops infinitely.
9     if true {
10         return;
11     }
12     loop {
13         let x = 1;
14         continue;
15     }
16 }
17
18 // END RUST SOURCE
19 // START rustc.main.SimplifyCfg-qualify-consts.after.mir
20 //    ...
21 //    bb1 (cleanup): {
22 //        resume;
23 //    }
24 //    ...
25 //    bb3: { // Entry into the loop
26 //        _1 = ();
27 //        goto -> bb4;
28 //    }
29 //    bb4: { // The loop_block
30 //        falseUnwind -> [real: bb5, cleanup: bb1];
31 //    }
32 //    bb5: { // The loop body (body_block)
33 //        StorageLive(_5);
34 //        _5 = const 1i32;
35 //        FakeRead(ForLet, _5);
36 //        StorageDead(_5);
37 //        goto -> bb4;
38 //    }
39 //    ...
40 // END rustc.main.SimplifyCfg-qualify-consts.after.mir