2017-11-16 18:08:34 -06:00
|
|
|
// revisions: ast mir
|
2017-11-19 16:37:59 -06:00
|
|
|
//[mir]compile-flags: -Z borrowck=mir
|
2017-11-16 18:08:34 -06:00
|
|
|
|
2017-01-14 11:59:10 -06:00
|
|
|
use std::cell::RefCell;
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let mut r = 0;
|
|
|
|
let s = 0;
|
|
|
|
let x = RefCell::new((&mut r,s));
|
|
|
|
|
|
|
|
let val: &_ = x.borrow().0;
|
2017-11-16 18:08:34 -06:00
|
|
|
//[ast]~^ ERROR borrowed value does not live long enough [E0597]
|
|
|
|
//[ast]~| NOTE temporary value dropped here while still borrowed
|
2017-12-14 11:57:34 -06:00
|
|
|
//[ast]~| NOTE temporary value does not live long enough
|
2017-11-16 18:08:34 -06:00
|
|
|
//[ast]~| NOTE consider using a `let` binding to increase its lifetime
|
2018-09-25 09:06:28 -05:00
|
|
|
//[mir]~^^^^^ ERROR temporary value dropped while borrowed [E0716]
|
2018-09-23 10:30:46 -05:00
|
|
|
//[mir]~| NOTE temporary value is freed at the end of this statement
|
|
|
|
//[mir]~| NOTE creates a temporary which is freed while still in use
|
2018-09-09 13:43:46 -05:00
|
|
|
//[mir]~| NOTE consider using a `let` binding to create a longer lived value
|
2017-01-14 11:59:10 -06:00
|
|
|
println!("{}", val);
|
2018-04-09 04:28:00 -05:00
|
|
|
//[mir]~^ borrow later used here
|
2017-01-14 11:59:10 -06:00
|
|
|
}
|
2017-11-16 18:08:34 -06:00
|
|
|
//[ast]~^ NOTE temporary value needs to live until here
|