]> git.proxmox.com Git - rustc.git/blob - src/test/mir-opt/nll/region-subtyping-basic.rs
New upstream version 1.28.0~beta.14+dfsg1
[rustc.git] / src / test / mir-opt / nll / region-subtyping-basic.rs
1 // Copyright 2012-2016 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 // Basic test for liveness constraints: the region (`R1`) that appears
12 // in the type of `p` includes the points after `&v[0]` up to (but not
13 // including) the call to `use_x`. The `else` branch is not included.
14
15 // compile-flags:-Zborrowck=mir -Zverbose
16 // ^^^^^^^^^ force compiler to dump more region information
17
18 #![allow(warnings)]
19
20 fn use_x(_: usize) -> bool { true }
21
22 fn main() {
23 let mut v = [1, 2, 3];
24 let p = &v[0];
25 let q = p;
26 if true {
27 use_x(*q);
28 } else {
29 use_x(22);
30 }
31 }
32
33 // END RUST SOURCE
34 // START rustc.main.nll.0.mir
35 // | '_#2r | {bb2[0..=6], bb3[0..=1]}
36 // | '_#3r | {bb2[1..=6], bb3[0..=1]}
37 // | '_#4r | {bb2[5..=6], bb3[0..=1]}
38 // END rustc.main.nll.0.mir
39 // START rustc.main.nll.0.mir
40 // let _6: &'_#4r usize;
41 // ...
42 // let _2: &'_#3r usize;
43 // ...
44 // _2 = &'_#2r _1[_3];
45 // ...
46 // _7 = _2;
47 // ...
48 // _6 = move _7;
49 // END rustc.main.nll.0.mir