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