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.
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.
12 //[mir]compile-flags: -Z borrowck=mir
14 use std::cell::RefCell;
19 let x = RefCell::new((&mut r,s));
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
31 //[mir]~^ borrow later used here
33 //[ast]~^ NOTE temporary value needs to live until here