rust/src/test/ui/borrowck/borrowck-lend-flow-loop.nll.stderr

27 lines
1011 B
Plaintext
Raw Normal View History

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 {
LL | borrow(&*v); //[ast]~ ERROR cannot borrow
2018-08-08 07:28:26 -05:00
| ^^^ immutable borrow occurs here
...
2018-08-08 07:28:26 -05:00
LL | *x = box 5;
| -- 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;
| -------- mutable borrow used here, in later iteration of loop
LL | borrow(&*v); //[ast]~ ERROR cannot borrow
2018-08-08 07:28:26 -05:00
| ^^^ immutable borrow occurs here
...
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`.