]> git.lizzy.rs Git - rust.git/blob - src/test/ui/borrowck/mutability-errors.stderr
Rollup merge of #102245 - ink-feather-org:const_cmp_by, r=fee1-dead
[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    |     ------ -- in this closure
127    |     |
128    |     expects `Fn` instead of `FnMut`
129 LL |         x = (1,);
130    |         ^^^^^^^^ cannot assign
131
132 error[E0594]: cannot assign to `x.0`, as `Fn` closures cannot mutate their captured variables
133   --> $DIR/mutability-errors.rs:41:9
134    |
135 LL | fn fn_ref<F: Fn()>(f: F) -> F { f }
136    |                       - change this to accept `FnMut` instead of `Fn`
137 ...
138 LL |     fn_ref(|| {
139    |     ------ -- in this closure
140    |     |
141    |     expects `Fn` instead of `FnMut`
142 LL |         x = (1,);
143 LL |         x.0 = 1;
144    |         ^^^^^^^ cannot assign
145
146 error[E0596]: cannot borrow `x` as mutable, as it is a captured variable in a `Fn` closure
147   --> $DIR/mutability-errors.rs:42:9
148    |
149 LL | fn fn_ref<F: Fn()>(f: F) -> F { f }
150    |                       - change this to accept `FnMut` instead of `Fn`
151 ...
152 LL |     fn_ref(|| {
153    |     ------ -- in this closure
154    |     |
155    |     expects `Fn` instead of `FnMut`
156 ...
157 LL |         &mut x;
158    |         ^^^^^^ cannot borrow as mutable
159
160 error[E0596]: cannot borrow `x.0` as mutable, as `Fn` closures cannot mutate their captured variables
161   --> $DIR/mutability-errors.rs:43:9
162    |
163 LL | fn fn_ref<F: Fn()>(f: F) -> F { f }
164    |                       - change this to accept `FnMut` instead of `Fn`
165 ...
166 LL |     fn_ref(|| {
167    |     ------ -- in this closure
168    |     |
169    |     expects `Fn` instead of `FnMut`
170 ...
171 LL |         &mut x.0;
172    |         ^^^^^^^^ cannot borrow as mutable
173
174 error[E0594]: cannot assign to `x`, as it is a captured variable in a `Fn` closure
175   --> $DIR/mutability-errors.rs:46:9
176    |
177 LL | fn fn_ref<F: Fn()>(f: F) -> F { f }
178    |                       - change this to accept `FnMut` instead of `Fn`
179 ...
180 LL |     fn_ref(move || {
181    |     ------ ------- in this closure
182    |     |
183    |     expects `Fn` instead of `FnMut`
184 LL |         x = (1,);
185    |         ^^^^^^^^ cannot assign
186
187 error[E0594]: cannot assign to `x.0`, as `Fn` closures cannot mutate their captured variables
188   --> $DIR/mutability-errors.rs:47:9
189    |
190 LL | fn fn_ref<F: Fn()>(f: F) -> F { f }
191    |                       - change this to accept `FnMut` instead of `Fn`
192 ...
193 LL |     fn_ref(move || {
194    |     ------ ------- in this closure
195    |     |
196    |     expects `Fn` instead of `FnMut`
197 LL |         x = (1,);
198 LL |         x.0 = 1;
199    |         ^^^^^^^ cannot assign
200
201 error[E0596]: cannot borrow `x` as mutable, as it is a captured variable in a `Fn` closure
202   --> $DIR/mutability-errors.rs:48:9
203    |
204 LL | fn fn_ref<F: Fn()>(f: F) -> F { f }
205    |                       - change this to accept `FnMut` instead of `Fn`
206 ...
207 LL |     fn_ref(move || {
208    |     ------ ------- in this closure
209    |     |
210    |     expects `Fn` instead of `FnMut`
211 ...
212 LL |         &mut x;
213    |         ^^^^^^ cannot borrow as mutable
214
215 error[E0596]: cannot borrow `x.0` as mutable, as `Fn` closures cannot mutate their captured variables
216   --> $DIR/mutability-errors.rs:49:9
217    |
218 LL | fn fn_ref<F: Fn()>(f: F) -> F { f }
219    |                       - change this to accept `FnMut` instead of `Fn`
220 ...
221 LL |     fn_ref(move || {
222    |     ------ ------- in this closure
223    |     |
224    |     expects `Fn` instead of `FnMut`
225 ...
226 LL |         &mut x.0;
227    |         ^^^^^^^^ cannot borrow as mutable
228
229 error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable
230   --> $DIR/mutability-errors.rs:54:5
231    |
232 LL | fn imm_local(x: (i32,)) {
233    |              - help: consider changing this to be mutable: `mut x`
234 LL |     &mut x;
235    |     ^^^^^^ cannot borrow as mutable
236
237 error[E0596]: cannot borrow `x.0` as mutable, as `x` is not declared as mutable
238   --> $DIR/mutability-errors.rs:55:5
239    |
240 LL | fn imm_local(x: (i32,)) {
241    |              - help: consider changing this to be mutable: `mut x`
242 LL |     &mut x;
243 LL |     &mut x.0;
244    |     ^^^^^^^^ cannot borrow as mutable
245
246 error[E0594]: cannot assign to `x`, as it is not declared as mutable
247   --> $DIR/mutability-errors.rs:60:9
248    |
249 LL | fn imm_capture(x: (i32,)) {
250    |                - help: consider changing this to be mutable: `mut x`
251 LL |     || {
252 LL |         x = (1,);
253    |         ^^^^^^^^ cannot assign
254
255 error[E0594]: cannot assign to `x.0`, as `x` is not declared as mutable
256   --> $DIR/mutability-errors.rs:61:9
257    |
258 LL | fn imm_capture(x: (i32,)) {
259    |                - help: consider changing this to be mutable: `mut x`
260 ...
261 LL |         x.0 = 1;
262    |         ^^^^^^^ cannot assign
263
264 error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable
265   --> $DIR/mutability-errors.rs:62:9
266    |
267 LL | fn imm_capture(x: (i32,)) {
268    |                - help: consider changing this to be mutable: `mut x`
269 ...
270 LL |         &mut x;
271    |         ^^^^^^ cannot borrow as mutable
272
273 error[E0596]: cannot borrow `x.0` as mutable, as `x` is not declared as mutable
274   --> $DIR/mutability-errors.rs:63:9
275    |
276 LL | fn imm_capture(x: (i32,)) {
277    |                - help: consider changing this to be mutable: `mut x`
278 ...
279 LL |         &mut x.0;
280    |         ^^^^^^^^ cannot borrow as mutable
281
282 error[E0594]: cannot assign to `x`, as it is not declared as mutable
283   --> $DIR/mutability-errors.rs:66:9
284    |
285 LL | fn imm_capture(x: (i32,)) {
286    |                - help: consider changing this to be mutable: `mut x`
287 ...
288 LL |         x = (1,);
289    |         ^^^^^^^^ cannot assign
290
291 error[E0594]: cannot assign to `x.0`, as `x` is not declared as mutable
292   --> $DIR/mutability-errors.rs:67:9
293    |
294 LL | fn imm_capture(x: (i32,)) {
295    |                - help: consider changing this to be mutable: `mut x`
296 ...
297 LL |         x.0 = 1;
298    |         ^^^^^^^ cannot assign
299
300 error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable
301   --> $DIR/mutability-errors.rs:68:9
302    |
303 LL | fn imm_capture(x: (i32,)) {
304    |                - help: consider changing this to be mutable: `mut x`
305 ...
306 LL |         &mut x;
307    |         ^^^^^^ cannot borrow as mutable
308
309 error[E0596]: cannot borrow `x.0` as mutable, as `x` is not declared as mutable
310   --> $DIR/mutability-errors.rs:69:9
311    |
312 LL | fn imm_capture(x: (i32,)) {
313    |                - help: consider changing this to be mutable: `mut x`
314 ...
315 LL |         &mut x.0;
316    |         ^^^^^^^^ cannot borrow as mutable
317
318 error[E0594]: cannot assign to immutable static item `X`
319   --> $DIR/mutability-errors.rs:76:5
320    |
321 LL |     X = (1,);
322    |     ^^^^^^^^ cannot assign
323
324 error[E0594]: cannot assign to `X.0`, as `X` is an immutable static item
325   --> $DIR/mutability-errors.rs:77:5
326    |
327 LL |     X.0 = 1;
328    |     ^^^^^^^ cannot assign
329
330 error[E0596]: cannot borrow immutable static item `X` as mutable
331   --> $DIR/mutability-errors.rs:78:5
332    |
333 LL |     &mut X;
334    |     ^^^^^^ cannot borrow as mutable
335
336 error[E0596]: cannot borrow `X.0` as mutable, as `X` is an immutable static item
337   --> $DIR/mutability-errors.rs:79:5
338    |
339 LL |     &mut X.0;
340    |     ^^^^^^^^ cannot borrow as mutable
341
342 error: aborting due to 38 previous errors
343
344 Some errors have detailed explanations: E0594, E0596.
345 For more information about an error, try `rustc --explain E0594`.