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