rust/src/test/ui/span/mut-ptr-cant-outlive-ref.rs

16 lines
287 B
Rust
Raw Normal View History

2013-11-21 21:30:34 -08:00
use std::cell::RefCell;
2013-11-16 14:35:35 -08: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
p.use_ref();
2013-11-16 14:35:35 -08:00
}
trait Fake { fn use_mut(&mut self) { } fn use_ref(&self) { } }
impl<T> Fake for T { }