]> git.lizzy.rs Git - rust.git/blob - src/test/mir-opt/nll/region-liveness-two-disjoint-uses.rs
Update the tools CI to use --no-fail-fast and --save-toolstates.
[rust.git] / src / test / mir-opt / nll / region-liveness-two-disjoint-uses.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 // Test for the subregion constraints. In this case, the region R3 on
12 // `p` includes two disjoint regions of the control-flow graph. The
13 // borrows in `&v[0]` and `&v[1]` each (in theory) have to outlive R3,
14 // but only at a particular point, and hence they wind up including
15 // distinct regions.
16
17 // compile-flags:-Znll -Zverbose
18 //                     ^^^^^^^^^ force compiler to dump more region information
19
20 #![allow(warnings)]
21
22 fn use_x(_: usize) -> bool { true }
23
24 fn main() {
25     let mut v = [1, 2, 3];
26     let mut p = &v[0];
27     if true {
28         use_x(*p);
29     } else {
30         use_x(22);
31     }
32
33     p = &v[1];
34     use_x(*p);
35 }
36
37 // END RUST SOURCE
38 // START rustc.main.nll.0.mir
39 // | '_#1r: {bb1[1], bb2[0], bb2[1]}
40 // ...
41 // | '_#3r: {bb7[2], bb7[3], bb7[4]}
42 // | '_#4r: {bb1[1], bb2[0], bb2[1], bb7[2], bb7[3], bb7[4]}
43 // ...
44 // let mut _2: &'_#4r usize;
45 // ...
46 // _2 = &'_#1r _1[_3];
47 // ...
48 // _2 = &'_#3r (*_10);
49 // END rustc.main.nll.0.mir