fork/rust

git clone https://git.julia.blue/fork/rust

borsAuto merge of #72883 - Mark-Simulacrum:stable-next, r=Mark-Simulacrum49cae55760d

1.44.0
1.5 KiB49 linesraw
1error[E0503]: cannot use `x` because it was mutably borrowed
2  --> $DIR/regions-escape-loop-via-vec.rs:5:11
3   |
4LL |     let mut _y = vec![&mut x];
5   |                       ------ borrow of `x` occurs here
6LL |     while x < 10 {
7   |           ^ use of borrowed `x`
8LL |         let mut z = x;
9LL |         _y.push(&mut z);
10   |         -- borrow later used here
11
12error[E0503]: cannot use `x` because it was mutably borrowed
13  --> $DIR/regions-escape-loop-via-vec.rs:6:21
14   |
15LL |     let mut _y = vec![&mut x];
16   |                       ------ borrow of `x` occurs here
17LL |     while x < 10 {
18LL |         let mut z = x;
19   |                     ^ use of borrowed `x`
20LL |         _y.push(&mut z);
21   |         -- borrow later used here
22
23error[E0597]: `z` does not live long enough
24  --> $DIR/regions-escape-loop-via-vec.rs:7:17
25   |
26LL |         _y.push(&mut z);
27   |         --      ^^^^^^ borrowed value does not live long enough
28   |         |
29   |         borrow later used here
30...
31LL |     }
32   |     - `z` dropped here while still borrowed
33
34error[E0503]: cannot use `x` because it was mutably borrowed
35  --> $DIR/regions-escape-loop-via-vec.rs:9:9
36   |
37LL |     let mut _y = vec![&mut x];
38   |                       ------ borrow of `x` occurs here
39...
40LL |         _y.push(&mut z);
41   |         -- borrow later used here
42LL |
43LL |         x += 1;
44   |         ^^^^^^ use of borrowed `x`
45
46error: aborting due to 4 previous errors
47
48Some errors have detailed explanations: E0503, E0597.
49For more information about an error, try `rustc --explain E0503`.