]> git.lizzy.rs Git - rust.git/blob - src/test/ui/issues/issue-36082.rs
Auto merge of #57088 - euclio:non-camel-case-early-lint, r=estebank
[rust.git] / src / test / ui / issues / issue-36082.rs
1 // Copyright 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 // revisions: ast mir
12 //[mir]compile-flags: -Z borrowck=mir
13
14 use std::cell::RefCell;
15
16 fn main() {
17     let mut r = 0;
18     let s = 0;
19     let x = RefCell::new((&mut r,s));
20
21     let val: &_ = x.borrow().0;
22     //[ast]~^ ERROR borrowed value does not live long enough [E0597]
23     //[ast]~| NOTE temporary value dropped here while still borrowed
24     //[ast]~| NOTE temporary value does not live long enough
25     //[ast]~| NOTE consider using a `let` binding to increase its lifetime
26     //[mir]~^^^^^ ERROR temporary value dropped while borrowed [E0716]
27     //[mir]~| NOTE temporary value is freed at the end of this statement
28     //[mir]~| NOTE creates a temporary which is freed while still in use
29     //[mir]~| NOTE consider using a `let` binding to create a longer lived value
30     println!("{}", val);
31     //[mir]~^ borrow later used here
32 }
33 //[ast]~^ NOTE temporary value needs to live until here