fork/rust

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

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

master
8.0 KiB218 linesraw
1error[E0505]: cannot move out of `arr[..]` because it is borrowed
2  --> $DIR/borrowck-move-ref-pattern.rs:8:24
3   |
4LL |     let mut arr = [U, U, U, U, U];
5   |         ------- binding `arr` declared here
6LL |     let hold_all = &arr;
7   |                    ---- borrow of `arr` occurs here
8LL |     let [ref _x0_hold, _x1, ref xs_hold @ ..] = arr;
9   |                        ^^^ move out of `arr[..]` occurs here
10LL |     _x1 = U;
11LL |     drop(hold_all);
12   |          -------- borrow later used here
13
14error[E0384]: cannot assign twice to immutable variable `_x1`
15  --> $DIR/borrowck-move-ref-pattern.rs:9:5
16   |
17LL |     let [ref _x0_hold, _x1, ref xs_hold @ ..] = arr;
18   |                        ---
19   |                        |
20   |                        first assignment to `_x1`
21   |                        help: consider making this binding mutable: `mut _x1`
22LL |     _x1 = U;
23   |     ^^^^^^^ cannot assign twice to immutable variable
24
25error[E0505]: cannot move out of `arr[..]` because it is borrowed
26  --> $DIR/borrowck-move-ref-pattern.rs:11:10
27   |
28LL |     let [ref _x0_hold, _x1, ref xs_hold @ ..] = arr;
29   |          ------------ borrow of `arr[..]` occurs here
30...
31LL |     let [_x0, ..] = arr;
32   |          ^^^ move out of `arr[..]` occurs here
33LL |     drop(_x0_hold);
34   |          -------- borrow later used here
35
36error[E0502]: cannot borrow `arr[..]` as mutable because it is also borrowed as immutable
37  --> $DIR/borrowck-move-ref-pattern.rs:13:16
38   |
39LL |     let [ref _x0_hold, _x1, ref xs_hold @ ..] = arr;
40   |                             ----------- immutable borrow occurs here
41...
42LL |     let [_, _, ref mut _x2, _x3, mut _x4] = arr;
43   |                ^^^^^^^^^^^ mutable borrow occurs here
44...
45LL |     drop(xs_hold);
46   |          ------- immutable borrow later used here
47
48error[E0505]: cannot move out of `arr[..]` because it is borrowed
49  --> $DIR/borrowck-move-ref-pattern.rs:13:29
50   |
51LL |     let [ref _x0_hold, _x1, ref xs_hold @ ..] = arr;
52   |                             ----------- borrow of `arr[..]` occurs here
53...
54LL |     let [_, _, ref mut _x2, _x3, mut _x4] = arr;
55   |                             ^^^ move out of `arr[..]` occurs here
56...
57LL |     drop(xs_hold);
58   |          ------- borrow later used here
59
60error[E0505]: cannot move out of `arr[..]` because it is borrowed
61  --> $DIR/borrowck-move-ref-pattern.rs:13:34
62   |
63LL |     let [ref _x0_hold, _x1, ref xs_hold @ ..] = arr;
64   |                             ----------- borrow of `arr[..]` occurs here
65...
66LL |     let [_, _, ref mut _x2, _x3, mut _x4] = arr;
67   |                                  ^^^^^^^ move out of `arr[..]` occurs here
68...
69LL |     drop(xs_hold);
70   |          ------- borrow later used here
71
72error[E0384]: cannot assign twice to immutable variable `_x1`
73  --> $DIR/borrowck-move-ref-pattern.rs:23:5
74   |
75LL |     let (ref _x0, _x1, ref _x2, ..) = tup;
76   |                   ---
77   |                   |
78   |                   first assignment to `_x1`
79   |                   help: consider making this binding mutable: `mut _x1`
80LL |     _x1 = U;
81   |     ^^^^^^^ cannot assign twice to immutable variable
82
83error[E0502]: cannot borrow `tup.0` as mutable because it is also borrowed as immutable
84  --> $DIR/borrowck-move-ref-pattern.rs:24:20
85   |
86LL |     let (ref _x0, _x1, ref _x2, ..) = tup;
87   |          ------- immutable borrow occurs here
88LL |     _x1 = U;
89LL |     let _x0_hold = &mut tup.0;
90   |                    ^^^^^^^^^^ mutable borrow occurs here
91LL |     let (ref mut _x0_hold, ..) = tup;
92LL |     *_x0 = U;
93   |     -------- immutable borrow later used here
94
95error[E0502]: cannot borrow `tup.0` as mutable because it is also borrowed as immutable
96  --> $DIR/borrowck-move-ref-pattern.rs:25:10
97   |
98LL |     let (ref _x0, _x1, ref _x2, ..) = tup;
99   |          ------- immutable borrow occurs here
100...
101LL |     let (ref mut _x0_hold, ..) = tup;
102   |          ^^^^^^^^^^^^^^^^ mutable borrow occurs here
103LL |     *_x0 = U;
104   |     -------- immutable borrow later used here
105
106error[E0594]: cannot assign to `*_x0`, which is behind a `&` reference
107  --> $DIR/borrowck-move-ref-pattern.rs:26:5
108   |
109LL |     *_x0 = U;
110   |     ^^^^^^^^ `_x0` is a `&` reference, so the data it refers to cannot be written
111   |
112help: consider changing this to be a mutable reference
113   |
114LL |     let (ref mut _x0, _x1, ref _x2, ..) = tup;
115   |              +++
116
117error[E0594]: cannot assign to `*_x2`, which is behind a `&` reference
118  --> $DIR/borrowck-move-ref-pattern.rs:27:5
119   |
120LL |     *_x2 = U;
121   |     ^^^^^^^^ `_x2` is a `&` reference, so the data it refers to cannot be written
122   |
123help: consider changing this to be a mutable reference
124   |
125LL |     let (ref _x0, _x1, ref mut _x2, ..) = tup;
126   |                            +++
127
128error[E0382]: use of moved value: `tup.1`
129  --> $DIR/borrowck-move-ref-pattern.rs:28:10
130   |
131LL |     let (ref _x0, _x1, ref _x2, ..) = tup;
132   |                   --- value moved here
133...
134LL |     drop(tup.1);
135   |          ^^^^^ value used here after move
136   |
137   = note: move occurs because `tup.1` has type `U`, which does not implement the `Copy` trait
138help: borrow this binding in the pattern to avoid moving the value
139   |
140LL |     let (ref _x0, ref _x1, ref _x2, ..) = tup;
141   |                   +++
142
143error[E0382]: borrow of moved value: `tup.1`
144  --> $DIR/borrowck-move-ref-pattern.rs:29:20
145   |
146LL |     drop(tup.1);
147   |          ----- value moved here
148LL |     let _x1_hold = &tup.1;
149   |                    ^^^^^^ value borrowed here after move
150   |
151   = note: move occurs because `tup.1` has type `U`, which does not implement the `Copy` trait
152
153error[E0502]: cannot borrow `tup.3` as immutable because it is also borrowed as mutable
154  --> $DIR/borrowck-move-ref-pattern.rs:31:20
155   |
156LL |     let (.., ref mut _x3) = tup;
157   |              ----------- mutable borrow occurs here
158LL |     let _x3_hold = &tup.3;
159   |                    ^^^^^^ immutable borrow occurs here
160...
161LL |     drop(_x3);
162   |          --- mutable borrow later used here
163
164error[E0499]: cannot borrow `tup.3` as mutable more than once at a time
165  --> $DIR/borrowck-move-ref-pattern.rs:32:20
166   |
167LL |     let (.., ref mut _x3) = tup;
168   |              ----------- first mutable borrow occurs here
169LL |     let _x3_hold = &tup.3;
170LL |     let _x3_hold = &mut tup.3;
171   |                    ^^^^^^^^^^ second mutable borrow occurs here
172...
173LL |     drop(_x3);
174   |          --- first borrow later used here
175
176error[E0499]: cannot borrow `tup.3` as mutable more than once at a time
177  --> $DIR/borrowck-move-ref-pattern.rs:33:14
178   |
179LL |     let (.., ref mut _x3) = tup;
180   |              ----------- first mutable borrow occurs here
181...
182LL |     let (.., ref mut _x4_hold) = tup;
183   |              ^^^^^^^^^^^^^^^^ second mutable borrow occurs here
184LL |     let (.., ref _x4_hold) = tup;
185LL |     drop(_x3);
186   |          --- first borrow later used here
187
188error[E0502]: cannot borrow `tup.3` as immutable because it is also borrowed as mutable
189  --> $DIR/borrowck-move-ref-pattern.rs:34:14
190   |
191LL |     let (.., ref mut _x3) = tup;
192   |              ----------- mutable borrow occurs here
193...
194LL |     let (.., ref _x4_hold) = tup;
195   |              ^^^^^^^^^^^^ immutable borrow occurs here
196LL |     drop(_x3);
197   |          --- mutable borrow later used here
198
199error[E0382]: use of moved value: `tup`
200  --> $DIR/borrowck-move-ref-pattern.rs:43:14
201   |
202LL |     let mut tup = (U, U, U);
203   |         ------- move occurs because `tup` has type `(U, U, U)`, which does not implement the `Copy` trait
204LL |     let c1 = || {
205   |              -- value moved into closure here
206LL |         let (ref _x0, _x1, _) = tup;
207   |                                 --- variable moved due to use in closure
208LL |     };
209LL |     let c2 = || {
210   |              ^^ value used here after move
211LL |
212LL |         let (ref mut _x0, _, _x2) = tup;
213   |                                     --- use occurs due to use in closure
214
215error: aborting due to 18 previous errors
216
217Some errors have detailed explanations: E0382, E0384, E0499, E0502, E0505, E0594.
218For more information about an error, try `rustc --explain E0382`.