]> git.proxmox.com Git - rustc.git/blame - src/test/mir-opt/nll/reborrow-basic.rs
New upstream version 1.29.0+dfsg1
[rustc.git] / src / test / mir-opt / nll / reborrow-basic.rs
CommitLineData
abe05a73
XL
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
83c7162d
XL
15// compile-flags:-Zborrowck=mir -Zverbose
16// ^^^^^^^^^ force compiler to dump more region information
abe05a73
XL
17
18#![allow(warnings)]
19
20fn use_x(_: &mut i32) -> bool { true }
21
22fn 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.main.nll.0.mir
8faf50e0 31// | '_#7r | U0 | {bb0[4], bb0[8..=17]}
abe05a73 32// ...
8faf50e0 33// | '_#9r | U0 | {bb0[10], bb0[14..=17]}
ff7c6d11 34// ...
ff7c6d11 35// let _4: &'_#9r mut i32;
94b46f34
XL
36// ...
37// let _2: &'_#7r mut i32;
abe05a73 38// END rustc.main.nll.0.mir