]> git.lizzy.rs Git - rust.git/blob - src/test/mir-opt/end_region_3.rs
Rollup merge of #45095 - bluss:discriminant-send-sync, 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.node4.SimplifyCfg-qualify-consts.after.mir
29 //     let mut _0: ();
30 //     let mut _1: bool;
31 //     let _3: &'26_1rs bool;
32 //     let _7: &'26_3rs bool;
33 //     let mut _2: ();
34 //     let mut _4: ();
35 //     let mut _5: bool;
36 //
37 //     bb0: {
38 //         StorageLive(_1);
39 //         goto -> bb1;
40 //     }
41 //     bb1: {
42 //         _1 = const true;
43 //         StorageLive(_3);
44 //         _3 = &'26_1rs _1;
45 //         StorageLive(_5);
46 //         _5 = _1;
47 //         switchInt(_5) -> [0u8: bb3, otherwise: bb2];
48 //     }
49 //     bb2: {
50 //         _0 = ();
51 //         StorageDead(_5);
52 //         EndRegion('26_1rs);
53 //         StorageDead(_3);
54 //         StorageDead(_1);
55 //         return;
56 //     }
57 //     bb3: {
58 //         _4 = ();
59 //         StorageDead(_5);
60 //         StorageLive(_7);
61 //         _7 = &'26_3rs _1;
62 //         _2 = ();
63 //         EndRegion('26_3rs);
64 //         StorageDead(_7);
65 //         EndRegion('26_1rs);
66 //         StorageDead(_3);
67 //         goto -> bb1;
68 //     }
69 // END rustc.node4.SimplifyCfg-qualify-consts.after.mir