rust/tests/ui/mut/mut-cant-alias.rs

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

15 lines
276 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
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 mut b = m.borrow_mut();
2014-03-21 00:06:51 -05:00
let b1 = &mut *b;
let b2 = &mut *b; //~ ERROR cannot borrow
b1.use_mut();
2013-11-16 16:35:35 -06:00
}
trait Fake { fn use_mut(&mut self) { } fn use_ref(&self) { } }
impl<T> Fake for T { }