]> git.lizzy.rs Git - rust.git/blob - src/test/ui/borrowck/mutability-errors.stderr
Rollup merge of #88090 - nbdd0121:inference, r=nikomatsakis
[rust.git] / src / test / ui / borrowck / mutability-errors.stderr
1 error[E0594]: cannot assign to `*x`, which is behind a `&` reference
2   --> $DIR/mutability-errors.rs:9:5
3    |
4 LL | fn named_ref(x: &(i32,)) {
5    |                 ------- help: consider changing this to be a mutable reference: `&mut (i32,)`
6 LL |     *x = (1,);
7    |     ^^^^^^^^^ `x` is a `&` reference, so the data it refers to cannot be written
8
9 error[E0594]: cannot assign to `x.0`, which is behind a `&` reference
10   --> $DIR/mutability-errors.rs:10:5
11    |
12 LL | fn named_ref(x: &(i32,)) {
13    |                 ------- help: consider changing this to be a mutable reference: `&mut (i32,)`
14 LL |     *x = (1,);
15 LL |     x.0 = 1;
16    |     ^^^^^^^ `x` is a `&` reference, so the data it refers to cannot be written
17
18 error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference
19   --> $DIR/mutability-errors.rs:11:5
20    |
21 LL | fn named_ref(x: &(i32,)) {
22    |                 ------- help: consider changing this to be a mutable reference: `&mut (i32,)`
23 ...
24 LL |     &mut *x;
25    |     ^^^^^^^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable
26
27 error[E0596]: cannot borrow `x.0` as mutable, as it is behind a `&` reference
28   --> $DIR/mutability-errors.rs:12:5
29    |
30 LL | fn named_ref(x: &(i32,)) {
31    |                 ------- help: consider changing this to be a mutable reference: `&mut (i32,)`
32 ...
33 LL |     &mut x.0;
34    |     ^^^^^^^^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable
35
36 error[E0594]: cannot assign to data in a `&` reference
37   --> $DIR/mutability-errors.rs:16:5
38    |
39 LL |     *f() = (1,);
40    |     ^^^^^^^^^^^ cannot assign
41
42 error[E0594]: cannot assign to data in a `&` reference
43   --> $DIR/mutability-errors.rs:17:5
44    |
45 LL |     f().0 = 1;
46    |     ^^^^^^^^^ cannot assign
47
48 error[E0596]: cannot borrow data in a `&` reference as mutable
49   --> $DIR/mutability-errors.rs:18:5
50    |
51 LL |     &mut *f();
52    |     ^^^^^^^^^ cannot borrow as mutable
53
54 error[E0596]: cannot borrow data in a `&` reference as mutable
55   --> $DIR/mutability-errors.rs:19:5
56    |
57 LL |     &mut f().0;
58    |     ^^^^^^^^^^ cannot borrow as mutable
59
60 error[E0594]: cannot assign to `*x`, which is behind a `*const` pointer
61   --> $DIR/mutability-errors.rs:23:5
62    |
63 LL | unsafe fn named_ptr(x: *const (i32,)) {
64    |                        ------------- help: consider changing this to be a mutable pointer: `*mut (i32,)`
65 LL |     *x = (1,);
66    |     ^^^^^^^^^ `x` is a `*const` pointer, so the data it refers to cannot be written
67
68 error[E0594]: cannot assign to `x.0`, which is behind a `*const` pointer
69   --> $DIR/mutability-errors.rs:24:5
70    |
71 LL | unsafe fn named_ptr(x: *const (i32,)) {
72    |                        ------------- help: consider changing this to be a mutable pointer: `*mut (i32,)`
73 LL |     *x = (1,);
74 LL |     (*x).0 = 1;
75    |     ^^^^^^^^^^ `x` is a `*const` pointer, so the data it refers to cannot be written
76
77 error[E0596]: cannot borrow `*x` as mutable, as it is behind a `*const` pointer
78   --> $DIR/mutability-errors.rs:25:5
79    |
80 LL | unsafe fn named_ptr(x: *const (i32,)) {
81    |                        ------------- help: consider changing this to be a mutable pointer: `*mut (i32,)`
82 ...
83 LL |     &mut *x;
84    |     ^^^^^^^ `x` is a `*const` pointer, so the data it refers to cannot be borrowed as mutable
85
86 error[E0596]: cannot borrow `x.0` as mutable, as it is behind a `*const` pointer
87   --> $DIR/mutability-errors.rs:26:5
88    |
89 LL | unsafe fn named_ptr(x: *const (i32,)) {
90    |                        ------------- help: consider changing this to be a mutable pointer: `*mut (i32,)`
91 ...
92 LL |     &mut (*x).0;
93    |     ^^^^^^^^^^^ `x` is a `*const` pointer, so the data it refers to cannot be borrowed as mutable
94
95 error[E0594]: cannot assign to data in a `*const` pointer
96   --> $DIR/mutability-errors.rs:30:5
97    |
98 LL |     *f() = (1,);
99    |     ^^^^^^^^^^^ cannot assign
100
101 error[E0594]: cannot assign to data in a `*const` pointer
102   --> $DIR/mutability-errors.rs:31:5
103    |
104 LL |     (*f()).0 = 1;
105    |     ^^^^^^^^^^^^ cannot assign
106
107 error[E0596]: cannot borrow data in a `*const` pointer as mutable
108   --> $DIR/mutability-errors.rs:32:5
109    |
110 LL |     &mut *f();
111    |     ^^^^^^^^^ cannot borrow as mutable
112
113 error[E0596]: cannot borrow data in a `*const` pointer as mutable
114   --> $DIR/mutability-errors.rs:33:5
115    |
116 LL |     &mut (*f()).0;
117    |     ^^^^^^^^^^^^^ cannot borrow as mutable
118
119 error[E0594]: cannot assign to `x`, as it is a captured variable in a `Fn` closure
120   --> $DIR/mutability-errors.rs:40:9
121    |
122 LL |   fn fn_ref<F: Fn()>(f: F) -> F { f }
123    |                         - change this to accept `FnMut` instead of `Fn`
124 ...
125 LL |       fn_ref(|| {
126    |  _____------_-
127    | |     |
128    | |     expects `Fn` instead of `FnMut`
129 LL | |         x = (1,);
130    | |         ^^^^^^^^ cannot assign
131 LL | |         x.0 = 1;
132 LL | |         &mut x;
133 LL | |         &mut x.0;
134 LL | |     });
135    | |_____- in this closure
136
137 error[E0594]: cannot assign to `x.0`, as `Fn` closures cannot mutate their captured variables
138   --> $DIR/mutability-errors.rs:41:9
139    |
140 LL |   fn fn_ref<F: Fn()>(f: F) -> F { f }
141    |                         - change this to accept `FnMut` instead of `Fn`
142 ...
143 LL |       fn_ref(|| {
144    |  _____------_-
145    | |     |
146    | |     expects `Fn` instead of `FnMut`
147 LL | |         x = (1,);
148 LL | |         x.0 = 1;
149    | |         ^^^^^^^ cannot assign
150 LL | |         &mut x;
151 LL | |         &mut x.0;
152 LL | |     });
153    | |_____- in this closure
154
155 error[E0596]: cannot borrow `x` as mutable, as it is a captured variable in a `Fn` closure
156   --> $DIR/mutability-errors.rs:42:9
157    |
158 LL |   fn fn_ref<F: Fn()>(f: F) -> F { f }
159    |                         - change this to accept `FnMut` instead of `Fn`
160 ...
161 LL |       fn_ref(|| {
162    |  _____------_-
163    | |     |
164    | |     expects `Fn` instead of `FnMut`
165 LL | |         x = (1,);
166 LL | |         x.0 = 1;
167 LL | |         &mut x;
168    | |         ^^^^^^ cannot borrow as mutable
169 LL | |         &mut x.0;
170 LL | |     });
171    | |_____- in this closure
172
173 error[E0596]: cannot borrow `x.0` as mutable, as `Fn` closures cannot mutate their captured variables
174   --> $DIR/mutability-errors.rs:43:9
175    |
176 LL |   fn fn_ref<F: Fn()>(f: F) -> F { f }
177    |                         - change this to accept `FnMut` instead of `Fn`
178 ...
179 LL |       fn_ref(|| {
180    |  _____------_-
181    | |     |
182    | |     expects `Fn` instead of `FnMut`
183 LL | |         x = (1,);
184 LL | |         x.0 = 1;
185 LL | |         &mut x;
186 LL | |         &mut x.0;
187    | |         ^^^^^^^^ cannot borrow as mutable
188 LL | |     });
189    | |_____- in this closure
190
191 error[E0594]: cannot assign to `x`, as it is a captured variable in a `Fn` closure
192   --> $DIR/mutability-errors.rs:46:9
193    |
194 LL |   fn fn_ref<F: Fn()>(f: F) -> F { f }
195    |                         - change this to accept `FnMut` instead of `Fn`
196 ...
197 LL |       fn_ref(move || {
198    |  _____------_-
199    | |     |
200    | |     expects `Fn` instead of `FnMut`
201 LL | |         x = (1,);
202    | |         ^^^^^^^^ cannot assign
203 LL | |         x.0 = 1;
204 LL | |         &mut x;
205 LL | |         &mut x.0;
206 LL | |     });
207    | |_____- in this closure
208
209 error[E0594]: cannot assign to `x.0`, as `Fn` closures cannot mutate their captured variables
210   --> $DIR/mutability-errors.rs:47:9
211    |
212 LL |   fn fn_ref<F: Fn()>(f: F) -> F { f }
213    |                         - change this to accept `FnMut` instead of `Fn`
214 ...
215 LL |       fn_ref(move || {
216    |  _____------_-
217    | |     |
218    | |     expects `Fn` instead of `FnMut`
219 LL | |         x = (1,);
220 LL | |         x.0 = 1;
221    | |         ^^^^^^^ cannot assign
222 LL | |         &mut x;
223 LL | |         &mut x.0;
224 LL | |     });
225    | |_____- in this closure
226
227 error[E0596]: cannot borrow `x` as mutable, as it is a captured variable in a `Fn` closure
228   --> $DIR/mutability-errors.rs:48:9
229    |
230 LL |   fn fn_ref<F: Fn()>(f: F) -> F { f }
231    |                         - change this to accept `FnMut` instead of `Fn`
232 ...
233 LL |       fn_ref(move || {
234    |  _____------_-
235    | |     |
236    | |     expects `Fn` instead of `FnMut`
237 LL | |         x = (1,);
238 LL | |         x.0 = 1;
239 LL | |         &mut x;
240    | |         ^^^^^^ cannot borrow as mutable
241 LL | |         &mut x.0;
242 LL | |     });
243    | |_____- in this closure
244
245 error[E0596]: cannot borrow `x.0` as mutable, as `Fn` closures cannot mutate their captured variables
246   --> $DIR/mutability-errors.rs:49:9
247    |
248 LL |   fn fn_ref<F: Fn()>(f: F) -> F { f }
249    |                         - change this to accept `FnMut` instead of `Fn`
250 ...
251 LL |       fn_ref(move || {
252    |  _____------_-
253    | |     |
254    | |     expects `Fn` instead of `FnMut`
255 LL | |         x = (1,);
256 LL | |         x.0 = 1;
257 LL | |         &mut x;
258 LL | |         &mut x.0;
259    | |         ^^^^^^^^ cannot borrow as mutable
260 LL | |     });
261    | |_____- in this closure
262
263 error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable
264   --> $DIR/mutability-errors.rs:54:5
265    |
266 LL | fn imm_local(x: (i32,)) {
267    |              - help: consider changing this to be mutable: `mut x`
268 LL |     &mut x;
269    |     ^^^^^^ cannot borrow as mutable
270
271 error[E0596]: cannot borrow `x.0` as mutable, as `x` is not declared as mutable
272   --> $DIR/mutability-errors.rs:55:5
273    |
274 LL | fn imm_local(x: (i32,)) {
275    |              - help: consider changing this to be mutable: `mut x`
276 LL |     &mut x;
277 LL |     &mut x.0;
278    |     ^^^^^^^^ cannot borrow as mutable
279
280 error[E0594]: cannot assign to `x`, as it is not declared as mutable
281   --> $DIR/mutability-errors.rs:60:9
282    |
283 LL | fn imm_capture(x: (i32,)) {
284    |                - help: consider changing this to be mutable: `mut x`
285 LL |     || {
286 LL |         x = (1,);
287    |         ^^^^^^^^ cannot assign
288
289 error[E0594]: cannot assign to `x.0`, as `x` is not declared as mutable
290   --> $DIR/mutability-errors.rs:61:9
291    |
292 LL | fn imm_capture(x: (i32,)) {
293    |                - help: consider changing this to be mutable: `mut x`
294 ...
295 LL |         x.0 = 1;
296    |         ^^^^^^^ cannot assign
297
298 error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable
299   --> $DIR/mutability-errors.rs:62:9
300    |
301 LL | fn imm_capture(x: (i32,)) {
302    |                - help: consider changing this to be mutable: `mut x`
303 ...
304 LL |         &mut x;
305    |         ^^^^^^ cannot borrow as mutable
306
307 error[E0596]: cannot borrow `x.0` as mutable, as `x` is not declared as mutable
308   --> $DIR/mutability-errors.rs:63:9
309    |
310 LL | fn imm_capture(x: (i32,)) {
311    |                - help: consider changing this to be mutable: `mut x`
312 ...
313 LL |         &mut x.0;
314    |         ^^^^^^^^ cannot borrow as mutable
315
316 error[E0594]: cannot assign to `x`, as it is not declared as mutable
317   --> $DIR/mutability-errors.rs:66:9
318    |
319 LL | fn imm_capture(x: (i32,)) {
320    |                - help: consider changing this to be mutable: `mut x`
321 ...
322 LL |         x = (1,);
323    |         ^^^^^^^^ cannot assign
324
325 error[E0594]: cannot assign to `x.0`, as `x` is not declared as mutable
326   --> $DIR/mutability-errors.rs:67:9
327    |
328 LL | fn imm_capture(x: (i32,)) {
329    |                - help: consider changing this to be mutable: `mut x`
330 ...
331 LL |         x.0 = 1;
332    |         ^^^^^^^ cannot assign
333
334 error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable
335   --> $DIR/mutability-errors.rs:68:9
336    |
337 LL | fn imm_capture(x: (i32,)) {
338    |                - help: consider changing this to be mutable: `mut x`
339 ...
340 LL |         &mut x;
341    |         ^^^^^^ cannot borrow as mutable
342
343 error[E0596]: cannot borrow `x.0` as mutable, as `x` is not declared as mutable
344   --> $DIR/mutability-errors.rs:69:9
345    |
346 LL | fn imm_capture(x: (i32,)) {
347    |                - help: consider changing this to be mutable: `mut x`
348 ...
349 LL |         &mut x.0;
350    |         ^^^^^^^^ cannot borrow as mutable
351
352 error[E0594]: cannot assign to immutable static item `X`
353   --> $DIR/mutability-errors.rs:76:5
354    |
355 LL |     X = (1,);
356    |     ^^^^^^^^ cannot assign
357
358 error[E0594]: cannot assign to `X.0`, as `X` is an immutable static item
359   --> $DIR/mutability-errors.rs:77:5
360    |
361 LL |     X.0 = 1;
362    |     ^^^^^^^ cannot assign
363
364 error[E0596]: cannot borrow immutable static item `X` as mutable
365   --> $DIR/mutability-errors.rs:78:5
366    |
367 LL |     &mut X;
368    |     ^^^^^^ cannot borrow as mutable
369
370 error[E0596]: cannot borrow `X.0` as mutable, as `X` is an immutable static item
371   --> $DIR/mutability-errors.rs:79:5
372    |
373 LL |     &mut X.0;
374    |     ^^^^^^^^ cannot borrow as mutable
375
376 error: aborting due to 38 previous errors
377
378 Some errors have detailed explanations: E0594, E0596.
379 For more information about an error, try `rustc --explain E0594`.