]> git.lizzy.rs Git - rust.git/blob - src/test/mir-opt/end_region_3.rs
Auto merge of #54240 - csmoe:nonzero_from, r=alexcrichton
[rust.git] / src / test / mir-opt / end_region_3.rs
1 // Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 // compile-flags: -Z identify_regions -Z emit-end-regions
12 // ignore-tidy-linelength
13
14 // Binding the borrow's subject outside the loop does not increase the
15 // scope of the borrow.
16
17 fn main() {
18     let mut a;
19     loop {
20         a = true;
21         let b = &a;
22         if a { break; }
23         let c = &a;
24     }
25 }
26
27 // END RUST SOURCE
28 // START rustc.main.SimplifyCfg-qualify-consts.after.mir
29 //     let mut _0: ();
30 //     ...
31 //     let _7: &'26_3rs bool;
32 //     ...
33 //     let _3: &'26_1rs bool;
34 //     ...
35 //     let mut _1: bool;
36 //     ...
37 //     let mut _2: ();
38 //     let mut _4: ();
39 //     let mut _5: bool;
40 //     let mut _6: !;
41 //     bb0: {
42 //         StorageLive(_1);
43 //         goto -> bb1;
44 //     }
45 //     bb1: {
46 //         falseUnwind -> [real: bb2, cleanup: bb3];
47 //     }
48 //     bb2: {
49 //         _1 = const true;
50 //         StorageLive(_3);
51 //         _3 = &'26_1rs _1;
52 //         FakeRead(ForLet, _3);
53 //         StorageLive(_5);
54 //         _5 = _1;
55 //         switchInt(move _5) -> [false: bb5, otherwise: bb4];
56 //     }
57 //     bb3: {
58 //         ...
59 //     }
60 //     bb4: {
61 //         _0 = ();
62 //         StorageDead(_5);
63 //         EndRegion('26_1rs);
64 //         StorageDead(_3);
65 //         StorageDead(_1);
66 //         return;
67 //     }
68 //     bb5: {
69 //         _4 = ();
70 //         StorageDead(_5);
71 //         StorageLive(_7);
72 //         _7 = &'26_3rs _1;
73 //         FakeRead(ForLet, _7);
74 //         _2 = ();
75 //         EndRegion('26_3rs);
76 //         StorageDead(_7);
77 //         EndRegion('26_1rs);
78 //         StorageDead(_3);
79 //         goto -> bb1;
80 //     }
81 // END rustc.main.SimplifyCfg-qualify-consts.after.mir