fork/rust

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

borsAuto merge of #103046 - JanBeh:PR_clarify_cmp_terminology, r=workingjubilee3bcad65fbf6

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