]> git.lizzy.rs Git - rust.git/blob - src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-and-ref.stderr
slice_patterns: remove gates in tests
[rust.git] / src / test / ui / pattern / bindings-after-at / borrowck-pat-ref-mut-and-ref.stderr
1 error: cannot borrow `z` as immutable because it is also borrowed as mutable
2   --> $DIR/borrowck-pat-ref-mut-and-ref.rs:10:9
3    |
4 LL |         ref mut z @ &mut Some(ref a) => {
5    |         ---------^^^^^^^^^^^^^-----^
6    |         |                     |
7    |         |                     immutable borrow occurs here
8    |         mutable borrow occurs here
9
10 error: cannot borrow `a` as mutable more than once at a time
11   --> $DIR/borrowck-pat-ref-mut-and-ref.rs:31:9
12    |
13 LL |     let ref mut a @ (ref b @ ref mut c) = u(); // sub-in-sub
14    |         ---------^^^^-----------------^
15    |         |            |       |
16    |         |            |       another mutable borrow occurs here
17    |         |            also borrowed as immutable here
18    |         first mutable borrow occurs here
19
20 error: cannot borrow `b` as mutable because it is also borrowed as immutable
21   --> $DIR/borrowck-pat-ref-mut-and-ref.rs:31:22
22    |
23 LL |     let ref mut a @ (ref b @ ref mut c) = u(); // sub-in-sub
24    |                      -----^^^---------
25    |                      |       |
26    |                      |       mutable borrow occurs here
27    |                      immutable borrow occurs here
28
29 error: cannot borrow `a` as mutable because it is also borrowed as immutable
30   --> $DIR/borrowck-pat-ref-mut-and-ref.rs:35:9
31    |
32 LL |     let ref a @ ref mut b = U;
33    |         -----^^^---------
34    |         |       |
35    |         |       mutable borrow occurs here
36    |         immutable borrow occurs here
37
38 error: cannot borrow `a` as immutable because it is also borrowed as mutable
39   --> $DIR/borrowck-pat-ref-mut-and-ref.rs:37:9
40    |
41 LL |     let ref mut a @ ref b = U;
42    |         ---------^^^-----
43    |         |           |
44    |         |           immutable borrow occurs here
45    |         mutable borrow occurs here
46
47 error: cannot borrow `a` as mutable because it is also borrowed as immutable
48   --> $DIR/borrowck-pat-ref-mut-and-ref.rs:39:9
49    |
50 LL |     let ref a @ (ref mut b, ref mut c) = (U, U);
51    |         -----^^^^---------^^---------^
52    |         |        |          |
53    |         |        |          mutable borrow occurs here
54    |         |        mutable borrow occurs here
55    |         immutable borrow occurs here
56
57 error: cannot borrow `a` as immutable because it is also borrowed as mutable
58   --> $DIR/borrowck-pat-ref-mut-and-ref.rs:41:9
59    |
60 LL |     let ref mut a @ (ref b, ref c) = (U, U);
61    |         ---------^^^^-----^^-----^
62    |         |            |      |
63    |         |            |      immutable borrow occurs here
64    |         |            immutable borrow occurs here
65    |         mutable borrow occurs here
66
67 error: cannot borrow `a` as immutable because it is also borrowed as mutable
68   --> $DIR/borrowck-pat-ref-mut-and-ref.rs:44:9
69    |
70 LL |     let ref mut a @ ref b = u();
71    |         ---------^^^-----
72    |         |           |
73    |         |           immutable borrow occurs here
74    |         mutable borrow occurs here
75
76 error: cannot borrow `a` as mutable because it is also borrowed as immutable
77   --> $DIR/borrowck-pat-ref-mut-and-ref.rs:49:9
78    |
79 LL |     let ref a @ ref mut b = u();
80    |         -----^^^---------
81    |         |       |
82    |         |       mutable borrow occurs here
83    |         immutable borrow occurs here
84
85 error: cannot borrow `a` as immutable because it is also borrowed as mutable
86   --> $DIR/borrowck-pat-ref-mut-and-ref.rs:55:9
87    |
88 LL |     let ref mut a @ ref b = U;
89    |         ---------^^^-----
90    |         |           |
91    |         |           immutable borrow occurs here
92    |         mutable borrow occurs here
93
94 error: cannot borrow `a` as mutable because it is also borrowed as immutable
95   --> $DIR/borrowck-pat-ref-mut-and-ref.rs:59:9
96    |
97 LL |     let ref a @ ref mut b = U;
98    |         -----^^^---------
99    |         |       |
100    |         |       mutable borrow occurs here
101    |         immutable borrow occurs here
102
103 error: cannot borrow `a` as immutable because it is also borrowed as mutable
104   --> $DIR/borrowck-pat-ref-mut-and-ref.rs:65:9
105    |
106 LL |         ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) => {
107    |         ---------^^^^^^-----^
108    |         |              |
109    |         |              immutable borrow occurs here
110    |         mutable borrow occurs here
111
112 error: cannot borrow `a` as immutable because it is also borrowed as mutable
113   --> $DIR/borrowck-pat-ref-mut-and-ref.rs:65:33
114    |
115 LL |         ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) => {
116    |                                 ---------^^^^^^^-----^
117    |                                 |               |
118    |                                 |               immutable borrow occurs here
119    |                                 mutable borrow occurs here
120
121 error: cannot borrow `a` as mutable because it is also borrowed as immutable
122   --> $DIR/borrowck-pat-ref-mut-and-ref.rs:74:9
123    |
124 LL |         ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) => {
125    |         -----^^^^^^---------^
126    |         |          |
127    |         |          mutable borrow occurs here
128    |         immutable borrow occurs here
129
130 error: cannot borrow `a` as mutable because it is also borrowed as immutable
131   --> $DIR/borrowck-pat-ref-mut-and-ref.rs:74:33
132    |
133 LL |         ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) => {
134    |                                 -----^^^^^^^---------^
135    |                                 |           |
136    |                                 |           mutable borrow occurs here
137    |                                 immutable borrow occurs here
138
139 error: cannot borrow `a` as mutable because it is also borrowed as immutable
140   --> $DIR/borrowck-pat-ref-mut-and-ref.rs:85:9
141    |
142 LL |         ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { *b = U; false } => {}
143    |         -----^^^^^^---------^
144    |         |          |
145    |         |          mutable borrow occurs here
146    |         immutable borrow occurs here
147
148 error: cannot borrow `a` as mutable because it is also borrowed as immutable
149   --> $DIR/borrowck-pat-ref-mut-and-ref.rs:85:33
150    |
151 LL |         ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { *b = U; false } => {}
152    |                                 -----^^^^^^^---------^
153    |                                 |           |
154    |                                 |           mutable borrow occurs here
155    |                                 immutable borrow occurs here
156
157 error: cannot borrow `a` as immutable because it is also borrowed as mutable
158   --> $DIR/borrowck-pat-ref-mut-and-ref.rs:92:9
159    |
160 LL |         ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) if { *a = Err(U); false } => {}
161    |         ---------^^^^^^-----^
162    |         |              |
163    |         |              immutable borrow occurs here
164    |         mutable borrow occurs here
165
166 error: cannot borrow `a` as immutable because it is also borrowed as mutable
167   --> $DIR/borrowck-pat-ref-mut-and-ref.rs:92:33
168    |
169 LL |         ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) if { *a = Err(U); false } => {}
170    |                                 ---------^^^^^^^-----^
171    |                                 |               |
172    |                                 |               immutable borrow occurs here
173    |                                 mutable borrow occurs here
174
175 error: cannot borrow `a` as mutable because it is also borrowed as immutable
176   --> $DIR/borrowck-pat-ref-mut-and-ref.rs:99:9
177    |
178 LL |         ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { drop(b); false } => {}
179    |         -----^^^^^^---------^
180    |         |          |
181    |         |          mutable borrow occurs here
182    |         immutable borrow occurs here
183
184 error: cannot borrow `a` as mutable because it is also borrowed as immutable
185   --> $DIR/borrowck-pat-ref-mut-and-ref.rs:99:33
186    |
187 LL |         ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { drop(b); false } => {}
188    |                                 -----^^^^^^^---------^
189    |                                 |           |
190    |                                 |           mutable borrow occurs here
191    |                                 immutable borrow occurs here
192
193 error: cannot borrow `a` as immutable because it is also borrowed as mutable
194   --> $DIR/borrowck-pat-ref-mut-and-ref.rs:107:9
195    |
196 LL |         ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) if { drop(a); false } => {}
197    |         ---------^^^^^^-----^
198    |         |              |
199    |         |              immutable borrow occurs here
200    |         mutable borrow occurs here
201
202 error: cannot borrow `a` as immutable because it is also borrowed as mutable
203   --> $DIR/borrowck-pat-ref-mut-and-ref.rs:107:33
204    |
205 LL |         ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) if { drop(a); false } => {}
206    |                                 ---------^^^^^^^-----^
207    |                                 |               |
208    |                                 |               immutable borrow occurs here
209    |                                 mutable borrow occurs here
210
211 error: cannot borrow `a` as mutable because it is also borrowed as immutable
212   --> $DIR/borrowck-pat-ref-mut-and-ref.rs:115:9
213    |
214 LL |     let ref a @ (ref mut b, ref mut c) = (U, U);
215    |         -----^^^^---------^^---------^
216    |         |        |          |
217    |         |        |          mutable borrow occurs here
218    |         |        mutable borrow occurs here
219    |         immutable borrow occurs here
220
221 error: cannot borrow `a` as mutable because it is also borrowed as immutable
222   --> $DIR/borrowck-pat-ref-mut-and-ref.rs:120:9
223    |
224 LL |     let ref a @ (ref mut b, ref mut c) = (U, U);
225    |         -----^^^^---------^^---------^
226    |         |        |          |
227    |         |        |          mutable borrow occurs here
228    |         |        mutable borrow occurs here
229    |         immutable borrow occurs here
230
231 error: cannot borrow `a` as mutable because it is also borrowed as immutable
232   --> $DIR/borrowck-pat-ref-mut-and-ref.rs:127:9
233    |
234 LL |     let ref a @ (ref mut b, ref mut c) = (U, U);
235    |         -----^^^^---------^^---------^
236    |         |        |          |
237    |         |        |          mutable borrow occurs here
238    |         |        mutable borrow occurs here
239    |         immutable borrow occurs here
240
241 error: cannot borrow `a` as immutable because it is also borrowed as mutable
242   --> $DIR/borrowck-pat-ref-mut-and-ref.rs:132:9
243    |
244 LL |     let ref mut a @ (ref b, ref c) = (U, U);
245    |         ---------^^^^-----^^-----^
246    |         |            |      |
247    |         |            |      immutable borrow occurs here
248    |         |            immutable borrow occurs here
249    |         mutable borrow occurs here
250
251 error: cannot borrow `a` as mutable because it is also borrowed as immutable
252   --> $DIR/borrowck-pat-ref-mut-and-ref.rs:24:11
253    |
254 LL |     fn f1(ref a @ ref mut b: U) {}
255    |           -----^^^---------
256    |           |       |
257    |           |       mutable borrow occurs here
258    |           immutable borrow occurs here
259
260 error: cannot borrow `a` as immutable because it is also borrowed as mutable
261   --> $DIR/borrowck-pat-ref-mut-and-ref.rs:26:11
262    |
263 LL |     fn f2(ref mut a @ ref b: U) {}
264    |           ---------^^^-----
265    |           |           |
266    |           |           immutable borrow occurs here
267    |           mutable borrow occurs here
268
269 error: cannot borrow `a` as mutable because it is also borrowed as immutable
270   --> $DIR/borrowck-pat-ref-mut-and-ref.rs:28:11
271    |
272 LL |     fn f3(ref a @ [ref b, ref mut mid @ .., ref c]: [U; 4]) {}
273    |           -----^^^^^^^^^^^----------------^^^^^^^^
274    |           |               |
275    |           |               mutable borrow occurs here
276    |           immutable borrow occurs here
277
278 error[E0502]: cannot borrow `_` as immutable because it is also borrowed as mutable
279   --> $DIR/borrowck-pat-ref-mut-and-ref.rs:10:31
280    |
281 LL |         ref mut z @ &mut Some(ref a) => {
282    |         ----------------------^^^^^-
283    |         |                     |
284    |         |                     immutable borrow occurs here
285    |         mutable borrow occurs here
286 ...
287 LL |             **z = None;
288    |             ---------- mutable borrow later used here
289
290 error[E0502]: cannot borrow `_` as immutable because it is also borrowed as mutable
291   --> $DIR/borrowck-pat-ref-mut-and-ref.rs:44:21
292    |
293 LL |     let ref mut a @ ref b = u();
294    |         ------------^^^^^
295    |         |           |
296    |         |           immutable borrow occurs here
297    |         mutable borrow occurs here
298 ...
299 LL |     *a = u();
300    |     -------- mutable borrow later used here
301
302 error[E0502]: cannot borrow `_` as mutable because it is also borrowed as immutable
303   --> $DIR/borrowck-pat-ref-mut-and-ref.rs:49:17
304    |
305 LL |     let ref a @ ref mut b = u();
306    |         --------^^^^^^^^^
307    |         |       |
308    |         |       mutable borrow occurs here
309    |         immutable borrow occurs here
310 ...
311 LL |     drop(a);
312    |          - immutable borrow later used here
313
314 error[E0502]: cannot borrow `_` as mutable because it is also borrowed as immutable
315   --> $DIR/borrowck-pat-ref-mut-and-ref.rs:74:20
316    |
317 LL |         ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) => {
318    |         -----------^^^^^^^^^-
319    |         |          |
320    |         |          mutable borrow occurs here
321    |         immutable borrow occurs here
322 ...
323 LL |             drop(a);
324    |                  - immutable borrow later used here
325
326 error[E0502]: cannot borrow `_` as mutable because it is also borrowed as immutable
327   --> $DIR/borrowck-pat-ref-mut-and-ref.rs:74:45
328    |
329 LL |         ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) => {
330    |                                 ------------^^^^^^^^^-
331    |                                 |           |
332    |                                 |           mutable borrow occurs here
333    |                                 immutable borrow occurs here
334 ...
335 LL |             drop(a);
336    |                  - immutable borrow later used here
337
338 error[E0594]: cannot assign to `*b`, as it is immutable for the pattern guard
339   --> $DIR/borrowck-pat-ref-mut-and-ref.rs:85:61
340    |
341 LL |         ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { *b = U; false } => {}
342    |                                                             ^^^^^^ cannot assign
343    |
344    = note: variables bound in patterns are immutable until the end of the pattern guard
345
346 error[E0594]: cannot assign to `*a`, as it is immutable for the pattern guard
347   --> $DIR/borrowck-pat-ref-mut-and-ref.rs:92:61
348    |
349 LL |         ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) if { *a = Err(U); false } => {}
350    |                                                             ^^^^^^^^^^^ cannot assign
351    |
352    = note: variables bound in patterns are immutable until the end of the pattern guard
353
354 error[E0507]: cannot move out of `b` in pattern guard
355   --> $DIR/borrowck-pat-ref-mut-and-ref.rs:99:66
356    |
357 LL |         ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { drop(b); false } => {}
358    |                                                                  ^ move occurs because `b` has type `&mut main::U`, which does not implement the `Copy` trait
359    |
360    = note: variables bound in patterns cannot be moved from until after the end of the pattern guard
361
362 error[E0507]: cannot move out of `b` in pattern guard
363   --> $DIR/borrowck-pat-ref-mut-and-ref.rs:99:66
364    |
365 LL |         ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { drop(b); false } => {}
366    |                                                                  ^ move occurs because `b` has type `&mut main::U`, which does not implement the `Copy` trait
367    |
368    = note: variables bound in patterns cannot be moved from until after the end of the pattern guard
369
370 error[E0507]: cannot move out of `a` in pattern guard
371   --> $DIR/borrowck-pat-ref-mut-and-ref.rs:107:66
372    |
373 LL |         ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) if { drop(a); false } => {}
374    |                                                                  ^ move occurs because `a` has type `&mut std::result::Result<main::U, main::U>`, which does not implement the `Copy` trait
375    |
376    = note: variables bound in patterns cannot be moved from until after the end of the pattern guard
377
378 error[E0507]: cannot move out of `a` in pattern guard
379   --> $DIR/borrowck-pat-ref-mut-and-ref.rs:107:66
380    |
381 LL |         ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) if { drop(a); false } => {}
382    |                                                                  ^ move occurs because `a` has type `&mut std::result::Result<main::U, main::U>`, which does not implement the `Copy` trait
383    |
384    = note: variables bound in patterns cannot be moved from until after the end of the pattern guard
385
386 error[E0502]: cannot borrow `_` as mutable because it is also borrowed as immutable
387   --> $DIR/borrowck-pat-ref-mut-and-ref.rs:120:18
388    |
389 LL |     let ref a @ (ref mut b, ref mut c) = (U, U);
390    |         ---------^^^^^^^^^------------
391    |         |        |
392    |         |        mutable borrow occurs here
393    |         immutable borrow occurs here
394 ...
395 LL |     drop(a);
396    |          - immutable borrow later used here
397
398 error[E0502]: cannot borrow `_` as mutable because it is also borrowed as immutable
399   --> $DIR/borrowck-pat-ref-mut-and-ref.rs:120:29
400    |
401 LL |     let ref a @ (ref mut b, ref mut c) = (U, U);
402    |         --------------------^^^^^^^^^-
403    |         |                   |
404    |         |                   mutable borrow occurs here
405    |         immutable borrow occurs here
406 ...
407 LL |     drop(a);
408    |          - immutable borrow later used here
409
410 error[E0502]: cannot borrow `_` as mutable because it is also borrowed as immutable
411   --> $DIR/borrowck-pat-ref-mut-and-ref.rs:127:18
412    |
413 LL |     let ref a @ (ref mut b, ref mut c) = (U, U);
414    |         ---------^^^^^^^^^------------
415    |         |        |
416    |         |        mutable borrow occurs here
417    |         immutable borrow occurs here
418 ...
419 LL |     drop(a);
420    |          - immutable borrow later used here
421
422 error[E0502]: cannot borrow `_` as mutable because it is also borrowed as immutable
423   --> $DIR/borrowck-pat-ref-mut-and-ref.rs:127:29
424    |
425 LL |     let ref a @ (ref mut b, ref mut c) = (U, U);
426    |         --------------------^^^^^^^^^-
427    |         |                   |
428    |         |                   mutable borrow occurs here
429    |         immutable borrow occurs here
430 ...
431 LL |     drop(a);
432    |          - immutable borrow later used here
433
434 error: aborting due to 45 previous errors
435
436 Some errors have detailed explanations: E0502, E0507, E0594.
437 For more information about an error, try `rustc --explain E0502`.