2017-12-05 17:37:06 -06:00
|
|
|
// This is the third counter-example from Niko's blog post
|
|
|
|
// smallcultfollowing.com/babysteps/blog/2017/03/01/nested-method-calls-via-two-phase-borrowing/
|
|
|
|
//
|
|
|
|
// It shows that not all nested method calls on `self` are magically
|
|
|
|
// allowed by this change. In particular, a nested `&mut` borrow is
|
|
|
|
// still disallowed.
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
|
|
|
|
|
|
|
|
let mut vec = vec![0, 1];
|
|
|
|
vec.get({
|
|
|
|
|
|
|
|
vec.push(2);
|
2018-04-09 04:28:00 -05:00
|
|
|
//~^ ERROR cannot borrow `vec` as mutable because it is also borrowed as immutable
|
2017-12-05 17:37:06 -06:00
|
|
|
|
|
|
|
0
|
|
|
|
});
|
|
|
|
}
|