2018-08-08 07:28:26 -05:00
|
|
|
error[E0502]: cannot borrow `*v` as immutable because it is also borrowed as mutable
|
|
|
|
--> $DIR/borrowck-lend-flow-loop.rs:45:16
|
|
|
|
|
|
|
|
|
LL | let mut x = &mut v;
|
|
|
|
| ------ mutable borrow occurs here
|
|
|
|
LL | for _ in 0..3 {
|
2018-11-05 05:59:40 -06:00
|
|
|
LL | borrow(&*v); //[ast]~ ERROR cannot borrow
|
2018-08-08 07:28:26 -05:00
|
|
|
| ^^^ immutable borrow occurs here
|
2018-11-05 05:59:40 -06:00
|
|
|
...
|
2018-08-08 07:28:26 -05:00
|
|
|
LL | *x = box 5;
|
2018-09-29 05:47:47 -05:00
|
|
|
| -- mutable borrow used here, in later iteration of loop
|
2018-08-08 07:28:26 -05:00
|
|
|
|
|
|
|
error[E0502]: cannot borrow `*v` as immutable because it is also borrowed as mutable
|
|
|
|
--> $DIR/borrowck-lend-flow-loop.rs:109:16
|
|
|
|
|
|
|
|
|
LL | **x += 1;
|
2018-09-29 05:47:47 -05:00
|
|
|
| -------- mutable borrow used here, in later iteration of loop
|
2018-11-05 05:59:40 -06:00
|
|
|
LL | borrow(&*v); //[ast]~ ERROR cannot borrow
|
2018-08-08 07:28:26 -05:00
|
|
|
| ^^^ immutable borrow occurs here
|
2018-11-05 05:59:40 -06:00
|
|
|
...
|
|
|
|
LL | x = &mut v; //[ast]~ ERROR cannot borrow
|
2018-08-08 07:28:26 -05:00
|
|
|
| ------ mutable borrow occurs here
|
|
|
|
|
|
|
|
error: aborting due to 2 previous errors
|
|
|
|
|
|
|
|
For more information about this error, try `rustc --explain E0502`.
|