fork/rust

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

borsAuto merge of #66089 - Mark-Simulacrum:stable-next, r=Mark-Simulacrum4560ea788cb

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