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

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

16 lines
287 B
Rust
Raw Normal View History

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