fork/rust

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

borsAuto merge of #69854 - pietroalbini:stable-next, r=Centrilb8cedc00407

1.42.0
12.2 KiB366 linesraw
1error[E0499]: cannot borrow `x` as mutable more than once at a time
2  --> $DIR/borrowck-describe-lvalue.rs:256:13
3   |
4LL |             let y = &mut x;
5   |                     ------ first mutable borrow occurs here
6LL |             &mut x;
7   |             ^^^^^^ second mutable borrow occurs here
8LL |             *y = 1;
9   |             ------ first borrow later used here
10
11error[E0499]: cannot borrow `x` as mutable more than once at a time
12  --> $DIR/borrowck-describe-lvalue.rs:266:20
13   |
14LL |                    let y = &mut x;
15   |                            ------ first mutable borrow occurs here
16LL |                    &mut x;
17   |                    ^^^^^^ second mutable borrow occurs here
18LL |                    *y = 1;
19   |                    ------ first borrow later used here
20
21error: captured variable cannot escape `FnMut` closure body
22  --> $DIR/borrowck-describe-lvalue.rs:264:16
23   |
24LL |              || {
25   |               - inferred to be a `FnMut` closure
26LL | /                || {
27LL | |                    let y = &mut x;
28LL | |                    &mut x;
29LL | |                    *y = 1;
30LL | |                    drop(y);
31LL | |                 }
32   | |_________________^ returns a closure that contains a reference to a captured variable, which then escapes the closure body
33   |
34   = note: `FnMut` closures only have access to their captured variables while they are executing...
35   = note: ...therefore, they cannot allow references to captured variables to escape
36
37error[E0503]: cannot use `f.x` because it was mutably borrowed
38  --> $DIR/borrowck-describe-lvalue.rs:39:9
39   |
40LL |         let x = f.x();
41   |                 - borrow of `f` occurs here
42LL |         f.x;
43   |         ^^^ use of borrowed `f`
44LL |         drop(x);
45   |              - borrow later used here
46
47error[E0503]: cannot use `g.0` because it was mutably borrowed
48  --> $DIR/borrowck-describe-lvalue.rs:46:9
49   |
50LL |         let x = g.x();
51   |                 - borrow of `g` occurs here
52LL |         g.0;
53   |         ^^^ use of borrowed `g`
54LL |         drop(x);
55   |              - borrow later used here
56
57error[E0503]: cannot use `h.0` because it was mutably borrowed
58  --> $DIR/borrowck-describe-lvalue.rs:53:9
59   |
60LL |         let x = &mut h.0;
61   |                 -------- borrow of `h.0` occurs here
62LL |         h.0;
63   |         ^^^ use of borrowed `h.0`
64LL |         drop(x);
65   |              - borrow later used here
66
67error[E0503]: cannot use `e.0` because it was mutably borrowed
68  --> $DIR/borrowck-describe-lvalue.rs:61:20
69   |
70LL |         let x = e.x();
71   |                 - borrow of `e` occurs here
72LL |         match e {
73LL |             Baz::X(value) => value
74   |                    ^^^^^ use of borrowed `e`
75LL |         };
76LL |         drop(x);
77   |              - borrow later used here
78
79error[E0503]: cannot use `u.a` because it was mutably borrowed
80  --> $DIR/borrowck-describe-lvalue.rs:69:9
81   |
82LL |         let x = &mut u.a;
83   |                 -------- borrow of `u.a` occurs here
84LL |         u.a;
85   |         ^^^ use of borrowed `u.a`
86LL |         drop(x);
87   |              - borrow later used here
88
89error[E0503]: cannot use `f.x` because it was mutably borrowed
90  --> $DIR/borrowck-describe-lvalue.rs:76:9
91   |
92LL |         let x = f.x();
93   |                 - borrow of `*f` occurs here
94LL |         f.x;
95   |         ^^^ use of borrowed `*f`
96LL |         drop(x);
97   |              - borrow later used here
98
99error[E0503]: cannot use `g.0` because it was mutably borrowed
100  --> $DIR/borrowck-describe-lvalue.rs:83:9
101   |
102LL |         let x = g.x();
103   |                 - borrow of `*g` occurs here
104LL |         g.0;
105   |         ^^^ use of borrowed `*g`
106LL |         drop(x);
107   |              - borrow later used here
108
109error[E0503]: cannot use `h.0` because it was mutably borrowed
110  --> $DIR/borrowck-describe-lvalue.rs:90:9
111   |
112LL |         let x = &mut h.0;
113   |                 -------- borrow of `h.0` occurs here
114LL |         h.0;
115   |         ^^^ use of borrowed `h.0`
116LL |         drop(x);
117   |              - borrow later used here
118
119error[E0503]: cannot use `e.0` because it was mutably borrowed
120  --> $DIR/borrowck-describe-lvalue.rs:98:20
121   |
122LL |         let x = e.x();
123   |                 - borrow of `*e` occurs here
124LL |         match *e {
125LL |             Baz::X(value) => value
126   |                    ^^^^^ use of borrowed `*e`
127...
128LL |         drop(x);
129   |              - borrow later used here
130
131error[E0503]: cannot use `u.a` because it was mutably borrowed
132  --> $DIR/borrowck-describe-lvalue.rs:107:9
133   |
134LL |         let x = &mut u.a;
135   |                 -------- borrow of `u.a` occurs here
136LL |         u.a;
137   |         ^^^ use of borrowed `u.a`
138LL |         drop(x);
139   |              - borrow later used here
140
141error[E0503]: cannot use `v[..]` because it was mutably borrowed
142  --> $DIR/borrowck-describe-lvalue.rs:115:15
143   |
144LL |         let x = &mut v;
145   |                 ------ borrow of `v` occurs here
146LL |         match v {
147LL |             &[x, _, .., _, _] => println!("{}", x),
148   |               ^ use of borrowed `v`
149...
150LL |         drop(x);
151   |              - borrow later used here
152
153error[E0503]: cannot use `v[..]` because it was mutably borrowed
154  --> $DIR/borrowck-describe-lvalue.rs:120:18
155   |
156LL |         let x = &mut v;
157   |                 ------ borrow of `v` occurs here
158...
159LL |             &[_, x, .., _, _] => println!("{}", x),
160   |                  ^ use of borrowed `v`
161...
162LL |         drop(x);
163   |              - borrow later used here
164
165error[E0503]: cannot use `v[..]` because it was mutably borrowed
166  --> $DIR/borrowck-describe-lvalue.rs:125:25
167   |
168LL |         let x = &mut v;
169   |                 ------ borrow of `v` occurs here
170...
171LL |             &[_, _, .., x, _] => println!("{}", x),
172   |                         ^ use of borrowed `v`
173...
174LL |         drop(x);
175   |              - borrow later used here
176
177error[E0503]: cannot use `v[..]` because it was mutably borrowed
178  --> $DIR/borrowck-describe-lvalue.rs:130:28
179   |
180LL |         let x = &mut v;
181   |                 ------ borrow of `v` occurs here
182...
183LL |             &[_, _, .., _, x] => println!("{}", x),
184   |                            ^ use of borrowed `v`
185...
186LL |         drop(x);
187   |              - borrow later used here
188
189error[E0503]: cannot use `v[..]` because it was mutably borrowed
190  --> $DIR/borrowck-describe-lvalue.rs:141:15
191   |
192LL |         let x = &mut v;
193   |                 ------ borrow of `v` occurs here
194LL |         match v {
195LL |             &[x @ ..] => println!("{:?}", x),
196   |               ^^^^^^ use of borrowed `v`
197...
198LL |         drop(x);
199   |              - borrow later used here
200
201error[E0503]: cannot use `v[..]` because it was mutably borrowed
202  --> $DIR/borrowck-describe-lvalue.rs:146:18
203   |
204LL |         let x = &mut v;
205   |                 ------ borrow of `v` occurs here
206...
207LL |             &[_, x @ ..] => println!("{:?}", x),
208   |                  ^^^^^^ use of borrowed `v`
209...
210LL |         drop(x);
211   |              - borrow later used here
212
213error[E0503]: cannot use `v[..]` because it was mutably borrowed
214  --> $DIR/borrowck-describe-lvalue.rs:151:15
215   |
216LL |         let x = &mut v;
217   |                 ------ borrow of `v` occurs here
218...
219LL |             &[x @ .., _] => println!("{:?}", x),
220   |               ^^^^^^ use of borrowed `v`
221...
222LL |         drop(x);
223   |              - borrow later used here
224
225error[E0503]: cannot use `v[..]` because it was mutably borrowed
226  --> $DIR/borrowck-describe-lvalue.rs:156:18
227   |
228LL |         let x = &mut v;
229   |                 ------ borrow of `v` occurs here
230...
231LL |             &[_, x @ .., _] => println!("{:?}", x),
232   |                  ^^^^^^ use of borrowed `v`
233...
234LL |         drop(x);
235   |              - borrow later used here
236
237error[E0503]: cannot use `e` because it was mutably borrowed
238  --> $DIR/borrowck-describe-lvalue.rs:169:13
239   |
240LL |         let x = &mut e;
241   |                 ------ borrow of `e` occurs here
242LL |         match e {
243LL |             E::A(ref ax) =>
244   |             ^^^^^^^^^^^^ use of borrowed `e`
245...
246LL |         drop(x);
247   |              - borrow later used here
248
249error[E0502]: cannot borrow `e.0` as immutable because it is also borrowed as mutable
250  --> $DIR/borrowck-describe-lvalue.rs:169:18
251   |
252LL |         let x = &mut e;
253   |                 ------ mutable borrow occurs here
254LL |         match e {
255LL |             E::A(ref ax) =>
256   |                  ^^^^^^ immutable borrow occurs here
257...
258LL |         drop(x);
259   |              - mutable borrow later used here
260
261error[E0502]: cannot borrow `e.x` as immutable because it is also borrowed as mutable
262  --> $DIR/borrowck-describe-lvalue.rs:173:23
263   |
264LL |         let x = &mut e;
265   |                 ------ mutable borrow occurs here
266...
267LL |             E::B { x: ref bx } =>
268   |                       ^^^^^^ immutable borrow occurs here
269...
270LL |         drop(x);
271   |              - mutable borrow later used here
272
273error[E0502]: cannot borrow `s.y.0` as immutable because it is also borrowed as mutable
274  --> $DIR/borrowck-describe-lvalue.rs:186:22
275   |
276LL |         let x = &mut s;
277   |                 ------ mutable borrow occurs here
278LL |         match s {
279LL |             S  { y: (ref y0, _), .. } =>
280   |                      ^^^^^^ immutable borrow occurs here
281...
282LL |         drop(x);
283   |              - mutable borrow later used here
284
285error[E0502]: cannot borrow `s.x.y` as immutable because it is also borrowed as mutable
286  --> $DIR/borrowck-describe-lvalue.rs:192:28
287   |
288LL |         let x = &mut s;
289   |                 ------ mutable borrow occurs here
290...
291LL |             S  { x: F { y: ref x0, .. }, .. } =>
292   |                            ^^^^^^ immutable borrow occurs here
293...
294LL |         drop(x);
295   |              - mutable borrow later used here
296
297error[E0503]: cannot use `*v` because it was mutably borrowed
298  --> $DIR/borrowck-describe-lvalue.rs:234:9
299   |
300LL |         let x = &mut v;
301   |                 ------ borrow of `v` occurs here
302LL |         v[0].y;
303   |         ^^^^ use of borrowed `v`
304...
305LL |         drop(x);
306   |              - borrow later used here
307
308error[E0503]: cannot use `v[_].y` because it was mutably borrowed
309  --> $DIR/borrowck-describe-lvalue.rs:234:9
310   |
311LL |         let x = &mut v;
312   |                 ------ borrow of `v` occurs here
313LL |         v[0].y;
314   |         ^^^^^^ use of borrowed `v`
315...
316LL |         drop(x);
317   |              - borrow later used here
318
319error[E0502]: cannot borrow `v[..].x` as immutable because it is also borrowed as mutable
320  --> $DIR/borrowck-describe-lvalue.rs:245:24
321   |
322LL |         let x = &mut v;
323   |                 ------ mutable borrow occurs here
324LL |         match v {
325LL |             &[_, F {x: ref xf, ..}] => println!("{}", xf),
326   |                        ^^^^^^ immutable borrow occurs here
327...
328LL |         drop(x);
329   |              - mutable borrow later used here
330
331error[E0502]: cannot borrow `*block.current` as immutable because it is also borrowed as mutable
332  --> $DIR/borrowck-describe-lvalue.rs:208:29
333   |
334LL |             let x = &mut block;
335   |                     ---------- mutable borrow occurs here
336LL |             let p: &'a u8 = &*block.current;
337   |                             ^^^^^^^^^^^^^^^ immutable borrow occurs here
338...
339LL |             drop(x);
340   |                  - mutable borrow later used here
341
342error[E0502]: cannot borrow `*block.current` as immutable because it is also borrowed as mutable
343  --> $DIR/borrowck-describe-lvalue.rs:223:33
344   |
345LL |             let x = &mut block;
346   |                     ---------- mutable borrow occurs here
347LL |             let p : *const u8 = &*(*block).current;
348   |                                 ^^^^^^^^^^^^^^^^^^ immutable borrow occurs here
349...
350LL |             drop(x);
351   |                  - mutable borrow later used here
352
353error[E0382]: use of moved value: `x`
354  --> $DIR/borrowck-describe-lvalue.rs:276:22
355   |
356LL |                 drop(x);
357   |                      - value moved here
358LL |                 drop(x);
359   |                      ^ value used here after move
360   |
361   = note: move occurs because `x` has type `std::vec::Vec<i32>`, which does not implement the `Copy` trait
362
363error: aborting due to 32 previous errors
364
365Some errors have detailed explanations: E0382, E0499, E0502, E0503.
366For more information about an error, try `rustc --explain E0382`.