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