fork/rust

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

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

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