]> git.proxmox.com Git - rustc.git/blame - src/test/mir-opt/end_region_3.rs
New upstream version 1.23.0+dfsg1
[rustc.git] / src / test / mir-opt / end_region_3.rs
CommitLineData
041b39d2
XL
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
ea8adc8c 11// compile-flags: -Z identify_regions -Z emit-end-regions
041b39d2
XL
12// ignore-tidy-linelength
13
14// Binding the borrow's subject outside the loop does not increase the
15// scope of the borrow.
16
17fn 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
abe05a73 28// START rustc.main.SimplifyCfg-qualify-consts.after.mir
041b39d2 29// let mut _0: ();
abe05a73 30// ...
041b39d2 31// let mut _1: bool;
abe05a73 32// ...
ea8adc8c 33// let _3: &'26_1rs bool;
abe05a73 34// ...
ea8adc8c 35// let _7: &'26_3rs bool;
abe05a73 36// ...
041b39d2
XL
37// let mut _2: ();
38// let mut _4: ();
39// let mut _5: bool;
abe05a73 40// let mut _6: !;
041b39d2
XL
41// bb0: {
42// StorageLive(_1);
43// goto -> bb1;
44// }
45// bb1: {
46// _1 = const true;
47// StorageLive(_3);
ea8adc8c 48// _3 = &'26_1rs _1;
041b39d2
XL
49// StorageLive(_5);
50// _5 = _1;
51// switchInt(_5) -> [0u8: bb3, otherwise: bb2];
52// }
53// bb2: {
54// _0 = ();
55// StorageDead(_5);
ea8adc8c 56// EndRegion('26_1rs);
041b39d2 57// StorageDead(_3);
041b39d2
XL
58// StorageDead(_1);
59// return;
60// }
61// bb3: {
62// _4 = ();
63// StorageDead(_5);
64// StorageLive(_7);
ea8adc8c 65// _7 = &'26_3rs _1;
041b39d2 66// _2 = ();
ea8adc8c 67// EndRegion('26_3rs);
041b39d2 68// StorageDead(_7);
ea8adc8c 69// EndRegion('26_1rs);
041b39d2 70// StorageDead(_3);
041b39d2
XL
71// goto -> bb1;
72// }
abe05a73 73// END rustc.main.SimplifyCfg-qualify-consts.after.mir