]> git.lizzy.rs Git - rust.git/blob - src/test/mir-opt/nll/reborrow-basic.rs
60a4da430b96e5fce16d96359ea8ea40ce8c4077
[rust.git] / src / test / mir-opt / nll / reborrow-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 reborrow constraints: the region (`R5`) that appears
12 // in the type of `r_a` must outlive the region (`R7`) that appears in
13 // the type of `r_b`
14
15 // compile-flags:-Znll -Zverbose
16 //                     ^^^^^^^^^ force compiler to dump more region information
17
18 #![allow(warnings)]
19
20 fn use_x(_: &mut i32) -> bool { true }
21
22 fn main() {
23     let mut foo: i32     = 22;
24     let r_a: &mut i32 = &mut foo;
25     let r_b: &mut i32 = &mut *r_a;
26     use_x(r_b);
27 }
28
29 // END RUST SOURCE
30 // START rustc.node13.nll.0.mir
31 // | '_#5r: {bb0[6], bb0[7], bb0[8], bb0[9], bb0[10], bb0[11], bb0[12], bb0[13], bb0[14]}
32 // ...
33 // | '_#7r: {bb0[11], bb0[12], bb0[13], bb0[14]}
34 // END rustc.node13.nll.0.mir
35 // START rustc.node13.nll.0.mir
36 // let _2: &'_#5r mut i32;
37 // ...
38 // let _4: &'_#7r mut i32;
39 // END rustc.node13.nll.0.mir