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 Permalink Normal View History

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