2013-11-21 21:30:34 -08:00
|
|
|
use std::cell::RefCell;
|
2013-11-16 14:35:35 -08:00
|
|
|
|
2018-05-25 12:36:58 +02:00
|
|
|
fn main() {
|
2015-01-31 17:23:42 +01:00
|
|
|
let m = RefCell::new(0);
|
2013-11-16 14:35:35 -08:00
|
|
|
let p;
|
|
|
|
{
|
|
|
|
let b = m.borrow();
|
2017-11-20 13:13:27 +01:00
|
|
|
p = &*b;
|
2017-12-13 17:27:23 -08:00
|
|
|
}
|
|
|
|
//~^^ ERROR `b` does not live long enough
|
2018-05-25 12:36:58 +02:00
|
|
|
p.use_ref();
|
2013-11-16 14:35:35 -08:00
|
|
|
}
|
2018-05-25 12:36:58 +02:00
|
|
|
|
|
|
|
trait Fake { fn use_mut(&mut self) { } fn use_ref(&self) { } }
|
|
|
|
impl<T> Fake for T { }
|