2017-05-27 17:58:52 +00:00
|
|
|
error[E0597]: `z` does not live long enough
|
2017-12-10 20:29:24 +00:00
|
|
|
--> $DIR/regions-escape-loop-via-vec.rs:19:5
|
2016-10-26 16:10:39 +00:00
|
|
|
|
|
2017-12-10 20:29:24 +00:00
|
|
|
17 | _y.push(&mut z);
|
2016-10-26 16:10:39 +00:00
|
|
|
| - borrow occurs here
|
2017-12-10 20:29:24 +00:00
|
|
|
18 | x += 1; //~ ERROR cannot assign
|
|
|
|
19 | }
|
2016-10-26 16:10:39 +00:00
|
|
|
| ^ `z` dropped here while still borrowed
|
2017-12-10 20:29:24 +00:00
|
|
|
20 | //~^ ERROR `z` does not live long enough
|
|
|
|
21 | }
|
2016-10-26 16:10:39 +00:00
|
|
|
| - borrowed value needs to live until here
|
|
|
|
|
|
|
|
error[E0503]: cannot use `x` because it was mutably borrowed
|
2017-12-10 20:29:24 +00:00
|
|
|
--> $DIR/regions-escape-loop-via-vec.rs:15:11
|
2016-10-26 16:10:39 +00:00
|
|
|
|
|
|
|
|
14 | let mut _y = vec![&mut x];
|
|
|
|
| - borrow of `x` occurs here
|
2017-12-10 20:29:24 +00:00
|
|
|
15 | while x < 10 { //~ ERROR cannot use `x` because it was mutably borrowed
|
2016-10-26 16:10:39 +00:00
|
|
|
| ^ use of borrowed `x`
|
|
|
|
|
|
|
|
error[E0503]: cannot use `x` because it was mutably borrowed
|
2017-12-10 20:29:24 +00:00
|
|
|
--> $DIR/regions-escape-loop-via-vec.rs:16:13
|
2016-10-26 16:10:39 +00:00
|
|
|
|
|
|
|
|
14 | let mut _y = vec![&mut x];
|
|
|
|
| - borrow of `x` occurs here
|
2017-12-10 20:29:24 +00:00
|
|
|
15 | while x < 10 { //~ ERROR cannot use `x` because it was mutably borrowed
|
|
|
|
16 | let mut z = x; //~ ERROR cannot use `x` because it was mutably borrowed
|
2016-10-26 16:10:39 +00:00
|
|
|
| ^^^^^ use of borrowed `x`
|
|
|
|
|
|
|
|
error[E0506]: cannot assign to `x` because it is borrowed
|
2017-12-10 20:29:24 +00:00
|
|
|
--> $DIR/regions-escape-loop-via-vec.rs:18:9
|
2016-10-26 16:10:39 +00:00
|
|
|
|
|
|
|
|
14 | let mut _y = vec![&mut x];
|
|
|
|
| - borrow of `x` occurs here
|
|
|
|
...
|
2017-12-10 20:29:24 +00:00
|
|
|
18 | x += 1; //~ ERROR cannot assign
|
2016-10-26 16:10:39 +00:00
|
|
|
| ^^^^^^ assignment to borrowed `x` occurs here
|
|
|
|
|
2017-07-02 10:49:30 +00:00
|
|
|
error: aborting due to 4 previous errors
|
2016-10-26 16:10:39 +00:00
|
|
|
|