summaryrefslogtreecommitdiffstats
path: root/tests/ui/pattern/move-ref-patterns/borrowck-move-ref-pattern.stderr
blob: 1b93267b397714cf694a084d0b7a3da0100c90dd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
error[E0505]: cannot move out of `arr[..]` because it is borrowed
  --> $DIR/borrowck-move-ref-pattern.rs:8:24
   |
LL |     let hold_all = &arr;
   |                    ---- borrow of `arr` occurs here
LL |     let [ref _x0_hold, _x1, ref xs_hold @ ..] = arr;
   |                        ^^^ move out of `arr[..]` occurs here
LL |     _x1 = U;
LL |     drop(hold_all);
   |          -------- borrow later used here

error[E0384]: cannot assign twice to immutable variable `_x1`
  --> $DIR/borrowck-move-ref-pattern.rs:9:5
   |
LL |     let [ref _x0_hold, _x1, ref xs_hold @ ..] = arr;
   |                        ---
   |                        |
   |                        first assignment to `_x1`
   |                        help: consider making this binding mutable: `mut _x1`
LL |     _x1 = U;
   |     ^^^^^^^ cannot assign twice to immutable variable

error[E0505]: cannot move out of `arr[..]` because it is borrowed
  --> $DIR/borrowck-move-ref-pattern.rs:11:10
   |
LL |     let [ref _x0_hold, _x1, ref xs_hold @ ..] = arr;
   |          ------------ borrow of `arr[..]` occurs here
...
LL |     let [_x0, ..] = arr;
   |          ^^^ move out of `arr[..]` occurs here
LL |     drop(_x0_hold);
   |          -------- borrow later used here

error[E0502]: cannot borrow `arr[..]` as mutable because it is also borrowed as immutable
  --> $DIR/borrowck-move-ref-pattern.rs:13:16
   |
LL |     let [ref _x0_hold, _x1, ref xs_hold @ ..] = arr;
   |                             ----------- immutable borrow occurs here
...
LL |     let [_, _, ref mut _x2, _x3, mut _x4] = arr;
   |                ^^^^^^^^^^^ mutable borrow occurs here
...
LL |     drop(xs_hold);
   |          ------- immutable borrow later used here

error[E0505]: cannot move out of `arr[..]` because it is borrowed
  --> $DIR/borrowck-move-ref-pattern.rs:13:29
   |
LL |     let [ref _x0_hold, _x1, ref xs_hold @ ..] = arr;
   |                             ----------- borrow of `arr[..]` occurs here
...
LL |     let [_, _, ref mut _x2, _x3, mut _x4] = arr;
   |                             ^^^ move out of `arr[..]` occurs here
...
LL |     drop(xs_hold);
   |          ------- borrow later used here

error[E0505]: cannot move out of `arr[..]` because it is borrowed
  --> $DIR/borrowck-move-ref-pattern.rs:13:34
   |
LL |     let [ref _x0_hold, _x1, ref xs_hold @ ..] = arr;
   |                             ----------- borrow of `arr[..]` occurs here
...
LL |     let [_, _, ref mut _x2, _x3, mut _x4] = arr;
   |                                  ^^^^^^^ move out of `arr[..]` occurs here
...
LL |     drop(xs_hold);
   |          ------- borrow later used here

error[E0384]: cannot assign twice to immutable variable `_x1`
  --> $DIR/borrowck-move-ref-pattern.rs:23:5
   |
LL |     let (ref _x0, _x1, ref _x2, ..) = tup;
   |                   ---
   |                   |
   |                   first assignment to `_x1`
   |                   help: consider making this binding mutable: `mut _x1`
LL |     _x1 = U;
   |     ^^^^^^^ cannot assign twice to immutable variable

error[E0502]: cannot borrow `tup.0` as mutable because it is also borrowed as immutable
  --> $DIR/borrowck-move-ref-pattern.rs:24:20
   |
LL |     let (ref _x0, _x1, ref _x2, ..) = tup;
   |          ------- immutable borrow occurs here
LL |     _x1 = U;
LL |     let _x0_hold = &mut tup.0;
   |                    ^^^^^^^^^^ mutable borrow occurs here
LL |     let (ref mut _x0_hold, ..) = tup;
LL |     *_x0 = U;
   |     -------- immutable borrow later used here

error[E0502]: cannot borrow `tup.0` as mutable because it is also borrowed as immutable
  --> $DIR/borrowck-move-ref-pattern.rs:25:10
   |
LL |     let (ref _x0, _x1, ref _x2, ..) = tup;
   |          ------- immutable borrow occurs here
...
LL |     let (ref mut _x0_hold, ..) = tup;
   |          ^^^^^^^^^^^^^^^^ mutable borrow occurs here
LL |     *_x0 = U;
   |     -------- immutable borrow later used here

error[E0594]: cannot assign to `*_x0`, which is behind a `&` reference
  --> $DIR/borrowck-move-ref-pattern.rs:26:5
   |
LL |     *_x0 = U;
   |     ^^^^^^^^ `_x0` is a `&` reference, so the data it refers to cannot be written
   |
help: consider changing this to be a mutable reference
   |
LL |     let (ref mut _x0, _x1, ref _x2, ..) = tup;
   |          ~~~~~~~~~~~

error[E0594]: cannot assign to `*_x2`, which is behind a `&` reference
  --> $DIR/borrowck-move-ref-pattern.rs:27:5
   |
LL |     *_x2 = U;
   |     ^^^^^^^^ `_x2` is a `&` reference, so the data it refers to cannot be written
   |
help: consider changing this to be a mutable reference
   |
LL |     let (ref _x0, _x1, ref mut _x2, ..) = tup;
   |                        ~~~~~~~~~~~

error[E0382]: use of moved value: `tup.1`
  --> $DIR/borrowck-move-ref-pattern.rs:28:10
   |
LL |     let (ref _x0, _x1, ref _x2, ..) = tup;
   |                   --- value moved here
...
LL |     drop(tup.1);
   |          ^^^^^ value used here after move
   |
   = note: move occurs because `tup.1` has type `U`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
   |
LL |     let (ref _x0, ref _x1, ref _x2, ..) = tup;
   |                   +++

error[E0382]: borrow of moved value: `tup.1`
  --> $DIR/borrowck-move-ref-pattern.rs:29:20
   |
LL |     drop(tup.1);
   |          ----- value moved here
LL |     let _x1_hold = &tup.1;
   |                    ^^^^^^ value borrowed here after move
   |
   = note: move occurs because `tup.1` has type `U`, which does not implement the `Copy` trait

error[E0502]: cannot borrow `tup.3` as immutable because it is also borrowed as mutable
  --> $DIR/borrowck-move-ref-pattern.rs:31:20
   |
LL |     let (.., ref mut _x3) = tup;
   |              ----------- mutable borrow occurs here
LL |     let _x3_hold = &tup.3;
   |                    ^^^^^^ immutable borrow occurs here
...
LL |     drop(_x3);
   |          --- mutable borrow later used here

error[E0499]: cannot borrow `tup.3` as mutable more than once at a time
  --> $DIR/borrowck-move-ref-pattern.rs:32:20
   |
LL |     let (.., ref mut _x3) = tup;
   |              ----------- first mutable borrow occurs here
LL |     let _x3_hold = &tup.3;
LL |     let _x3_hold = &mut tup.3;
   |                    ^^^^^^^^^^ second mutable borrow occurs here
...
LL |     drop(_x3);
   |          --- first borrow later used here

error[E0499]: cannot borrow `tup.3` as mutable more than once at a time
  --> $DIR/borrowck-move-ref-pattern.rs:33:14
   |
LL |     let (.., ref mut _x3) = tup;
   |              ----------- first mutable borrow occurs here
...
LL |     let (.., ref mut _x4_hold) = tup;
   |              ^^^^^^^^^^^^^^^^ second mutable borrow occurs here
LL |     let (.., ref _x4_hold) = tup;
LL |     drop(_x3);
   |          --- first borrow later used here

error[E0502]: cannot borrow `tup.3` as immutable because it is also borrowed as mutable
  --> $DIR/borrowck-move-ref-pattern.rs:34:14
   |
LL |     let (.., ref mut _x3) = tup;
   |              ----------- mutable borrow occurs here
...
LL |     let (.., ref _x4_hold) = tup;
   |              ^^^^^^^^^^^^ immutable borrow occurs here
LL |     drop(_x3);
   |          --- mutable borrow later used here

error[E0382]: use of moved value: `tup`
  --> $DIR/borrowck-move-ref-pattern.rs:43:14
   |
LL |     let mut tup = (U, U, U);
   |         ------- move occurs because `tup` has type `(U, U, U)`, which does not implement the `Copy` trait
LL |     let c1 = || {
   |              -- value moved into closure here
LL |         let (ref _x0, _x1, _) = tup;
   |                                 --- variable moved due to use in closure
LL |     };
LL |     let c2 = || {
   |              ^^ value used here after move
LL |
LL |         let (ref mut _x0, _, _x2) = tup;
   |                                     --- use occurs due to use in closure

error: aborting due to 18 previous errors

Some errors have detailed explanations: E0382, E0384, E0499, E0502, E0505, E0594.
For more information about an error, try `rustc --explain E0382`.