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