2014-08-12 14:25:41 -07:00
|
|
|
struct Foo {
|
2015-01-08 21:54:35 +11:00
|
|
|
x: isize,
|
2014-08-12 14:25:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn main() {
|
|
|
|
|
let mut this = &mut Foo {
|
|
|
|
|
x: 1,
|
|
|
|
|
};
|
2015-02-01 12:44:15 -05:00
|
|
|
let mut r = || {
|
2014-08-12 14:25:41 -07:00
|
|
|
let p = &this.x;
|
|
|
|
|
&mut this.x; //~ ERROR cannot borrow
|
2018-08-15 01:16:05 +02:00
|
|
|
p.use_ref();
|
2014-08-12 14:25:41 -07:00
|
|
|
};
|
|
|
|
|
r()
|
|
|
|
|
}
|
2018-08-15 01:16:05 +02:00
|
|
|
|
|
|
|
|
trait Fake { fn use_mut(&mut self) { } fn use_ref(&self) { } }
|
|
|
|
|
impl<T> Fake for T { }
|