]> git.lizzy.rs Git - rust.git/blob - src/test/ui/borrowck/mutability-errors.stderr
Auto merge of #54624 - arielb1:evaluate-outlives, r=nikomatsakis
[rust.git] / src / test / ui / borrowck / mutability-errors.stderr
1 error[E0594]: cannot assign to immutable borrowed content `*x`
2   --> $DIR/mutability-errors.rs:19:5
3    |
4 LL | fn named_ref(x: &(i32,)) {
5    |                 ------- use `&mut (i32,)` here to make mutable
6 LL |     *x = (1,); //~ ERROR
7    |     ^^^^^^^^^ cannot borrow as mutable
8
9 error[E0594]: cannot assign to field `x.0` of immutable binding
10   --> $DIR/mutability-errors.rs:20:5
11    |
12 LL | fn named_ref(x: &(i32,)) {
13    |                 ------- use `&mut (i32,)` here to make mutable
14 LL |     *x = (1,); //~ ERROR
15 LL |     x.0 = 1; //~ ERROR
16    |     ^^^^^^^ cannot mutably borrow field of immutable binding
17
18 error[E0596]: cannot borrow immutable borrowed content `*x` as mutable
19   --> $DIR/mutability-errors.rs:21:10
20    |
21 LL | fn named_ref(x: &(i32,)) {
22    |                 ------- use `&mut (i32,)` here to make mutable
23 ...
24 LL |     &mut *x; //~ ERROR
25    |          ^^ cannot borrow as mutable
26
27 error[E0596]: cannot borrow field `x.0` of immutable binding as mutable
28   --> $DIR/mutability-errors.rs:22:10
29    |
30 LL | fn named_ref(x: &(i32,)) {
31    |                 ------- use `&mut (i32,)` here to make mutable
32 ...
33 LL |     &mut x.0; //~ ERROR
34    |          ^^^ cannot mutably borrow field of immutable binding
35
36 error[E0594]: cannot assign to immutable borrowed content
37   --> $DIR/mutability-errors.rs:26:5
38    |
39 LL |     *f() = (1,); //~ ERROR
40    |     ^^^^^^^^^^^ cannot borrow as mutable
41
42 error[E0594]: cannot assign to field of immutable binding
43   --> $DIR/mutability-errors.rs:27:5
44    |
45 LL |     f().0 = 1; //~ ERROR
46    |     ^^^^^^^^^ cannot mutably borrow field of immutable binding
47
48 error[E0596]: cannot borrow immutable borrowed content as mutable
49   --> $DIR/mutability-errors.rs:28:10
50    |
51 LL |     &mut *f(); //~ ERROR
52    |          ^^^^ cannot borrow as mutable
53
54 error[E0596]: cannot borrow field of immutable binding as mutable
55   --> $DIR/mutability-errors.rs:29:10
56    |
57 LL |     &mut f().0; //~ ERROR
58    |          ^^^^^ cannot mutably borrow field of immutable binding
59
60 error[E0594]: cannot assign to immutable dereference of raw pointer `*x`
61   --> $DIR/mutability-errors.rs:33:5
62    |
63 LL |     *x = (1,); //~ ERROR
64    |     ^^^^^^^^^ cannot borrow as mutable
65
66 error[E0594]: cannot assign to field `x.0` of immutable binding
67   --> $DIR/mutability-errors.rs:34:5
68    |
69 LL |     (*x).0 = 1; //~ ERROR
70    |     ^^^^^^^^^^ cannot mutably borrow field of immutable binding
71
72 error[E0596]: cannot borrow immutable dereference of raw pointer `*x` as mutable
73   --> $DIR/mutability-errors.rs:35:10
74    |
75 LL |     &mut *x; //~ ERROR
76    |          ^^ cannot borrow as mutable
77
78 error[E0596]: cannot borrow field `x.0` of immutable binding as mutable
79   --> $DIR/mutability-errors.rs:36:10
80    |
81 LL |     &mut (*x).0; //~ ERROR
82    |          ^^^^^^ cannot mutably borrow field of immutable binding
83
84 error[E0594]: cannot assign to immutable dereference of raw pointer
85   --> $DIR/mutability-errors.rs:40:5
86    |
87 LL |     *f() = (1,); //~ ERROR
88    |     ^^^^^^^^^^^ cannot borrow as mutable
89
90 error[E0594]: cannot assign to field of immutable binding
91   --> $DIR/mutability-errors.rs:41:5
92    |
93 LL |     (*f()).0 = 1; //~ ERROR
94    |     ^^^^^^^^^^^^ cannot mutably borrow field of immutable binding
95
96 error[E0596]: cannot borrow immutable dereference of raw pointer as mutable
97   --> $DIR/mutability-errors.rs:42:10
98    |
99 LL |     &mut *f(); //~ ERROR
100    |          ^^^^ cannot borrow as mutable
101
102 error[E0596]: cannot borrow field of immutable binding as mutable
103   --> $DIR/mutability-errors.rs:43:10
104    |
105 LL |     &mut (*f()).0; //~ ERROR
106    |          ^^^^^^^^ cannot mutably borrow field of immutable binding
107
108 error[E0387]: cannot assign to data in a captured outer variable in an `Fn` closure
109   --> $DIR/mutability-errors.rs:50:9
110    |
111 LL |         x = (1,); //~ ERROR
112    |         ^^^^^^^^
113    |
114 help: consider changing this closure to take self by mutable reference
115   --> $DIR/mutability-errors.rs:49:12
116    |
117 LL |       fn_ref(|| {
118    |  ____________^
119 LL | |         x = (1,); //~ ERROR
120 LL | |         x.0 = 1; //~ ERROR
121 LL | |         &mut x; //~ ERROR
122 LL | |         &mut x.0; //~ ERROR
123 LL | |     });
124    | |_____^
125
126 error[E0387]: cannot assign to data in a captured outer variable in an `Fn` closure
127   --> $DIR/mutability-errors.rs:51:9
128    |
129 LL |         x.0 = 1; //~ ERROR
130    |         ^^^^^^^
131    |
132 help: consider changing this closure to take self by mutable reference
133   --> $DIR/mutability-errors.rs:49:12
134    |
135 LL |       fn_ref(|| {
136    |  ____________^
137 LL | |         x = (1,); //~ ERROR
138 LL | |         x.0 = 1; //~ ERROR
139 LL | |         &mut x; //~ ERROR
140 LL | |         &mut x.0; //~ ERROR
141 LL | |     });
142    | |_____^
143
144 error[E0387]: cannot borrow data mutably in a captured outer variable in an `Fn` closure
145   --> $DIR/mutability-errors.rs:52:14
146    |
147 LL |         &mut x; //~ ERROR
148    |              ^
149    |
150 help: consider changing this closure to take self by mutable reference
151   --> $DIR/mutability-errors.rs:49:12
152    |
153 LL |       fn_ref(|| {
154    |  ____________^
155 LL | |         x = (1,); //~ ERROR
156 LL | |         x.0 = 1; //~ ERROR
157 LL | |         &mut x; //~ ERROR
158 LL | |         &mut x.0; //~ ERROR
159 LL | |     });
160    | |_____^
161
162 error[E0387]: cannot borrow data mutably in a captured outer variable in an `Fn` closure
163   --> $DIR/mutability-errors.rs:53:14
164    |
165 LL |         &mut x.0; //~ ERROR
166    |              ^^^
167    |
168 help: consider changing this closure to take self by mutable reference
169   --> $DIR/mutability-errors.rs:49:12
170    |
171 LL |       fn_ref(|| {
172    |  ____________^
173 LL | |         x = (1,); //~ ERROR
174 LL | |         x.0 = 1; //~ ERROR
175 LL | |         &mut x; //~ ERROR
176 LL | |         &mut x.0; //~ ERROR
177 LL | |     });
178    | |_____^
179
180 error[E0594]: cannot assign to captured outer variable in an `Fn` closure
181   --> $DIR/mutability-errors.rs:56:9
182    |
183 LL |         x = (1,); //~ ERROR
184    |         ^^^^^^^^
185    |
186    = note: `Fn` closures cannot capture their enclosing environment for modifications
187 help: consider changing this closure to take self by mutable reference
188   --> $DIR/mutability-errors.rs:55:12
189    |
190 LL |       fn_ref(move || {
191    |  ____________^
192 LL | |         x = (1,); //~ ERROR
193 LL | |         x.0 = 1; //~ ERROR
194 LL | |         &mut x; //~ ERROR
195 LL | |         &mut x.0; //~ ERROR
196 LL | |     });
197    | |_____^
198
199 error[E0594]: cannot assign to field `x.0` of immutable binding
200   --> $DIR/mutability-errors.rs:57:9
201    |
202 LL |         x.0 = 1; //~ ERROR
203    |         ^^^^^^^ cannot mutably borrow field of immutable binding
204
205 error[E0596]: cannot borrow captured outer variable in an `Fn` closure as mutable
206   --> $DIR/mutability-errors.rs:58:14
207    |
208 LL |         &mut x; //~ ERROR
209    |              ^
210    |
211 help: consider changing this closure to take self by mutable reference
212   --> $DIR/mutability-errors.rs:55:12
213    |
214 LL |       fn_ref(move || {
215    |  ____________^
216 LL | |         x = (1,); //~ ERROR
217 LL | |         x.0 = 1; //~ ERROR
218 LL | |         &mut x; //~ ERROR
219 LL | |         &mut x.0; //~ ERROR
220 LL | |     });
221    | |_____^
222
223 error[E0596]: cannot borrow field `x.0` of immutable binding as mutable
224   --> $DIR/mutability-errors.rs:59:14
225    |
226 LL |         &mut x.0; //~ ERROR
227    |              ^^^ cannot mutably borrow field of immutable binding
228
229 error[E0596]: cannot borrow immutable argument `x` as mutable
230   --> $DIR/mutability-errors.rs:64:10
231    |
232 LL | fn imm_local(x: (i32,)) {
233    |              - help: make this binding mutable: `mut x`
234 LL |     &mut x; //~ ERROR
235    |          ^ cannot borrow mutably
236
237 error[E0596]: cannot borrow field `x.0` of immutable binding as mutable
238   --> $DIR/mutability-errors.rs:65:10
239    |
240 LL | fn imm_local(x: (i32,)) {
241    |              - help: make this binding mutable: `mut x`
242 LL |     &mut x; //~ ERROR
243 LL |     &mut x.0; //~ ERROR
244    |          ^^^ cannot mutably borrow field of immutable binding
245
246 error[E0595]: closure cannot assign to immutable argument `x`
247   --> $DIR/mutability-errors.rs:69:5
248    |
249 LL | fn imm_capture(x: (i32,)) {
250    |                - help: make this binding mutable: `mut x`
251 LL |     || { //~ ERROR
252    |     ^^ cannot borrow mutably
253
254 error[E0594]: cannot assign to captured outer variable in an `FnMut` closure
255   --> $DIR/mutability-errors.rs:76:9
256    |
257 LL | fn imm_capture(x: (i32,)) {
258    |                - help: consider making `x` mutable: `mut x`
259 ...
260 LL |         x = (1,); //~ ERROR
261    |         ^^^^^^^^
262
263 error[E0594]: cannot assign to field `x.0` of immutable binding
264   --> $DIR/mutability-errors.rs:77:9
265    |
266 LL |         x.0 = 1; //~ ERROR
267    |         ^^^^^^^ cannot mutably borrow field of immutable binding
268
269 error[E0596]: cannot borrow captured outer variable in an `FnMut` closure as mutable
270   --> $DIR/mutability-errors.rs:78:14
271    |
272 LL |         &mut x; //~ ERROR
273    |              ^
274
275 error[E0596]: cannot borrow field `x.0` of immutable binding as mutable
276   --> $DIR/mutability-errors.rs:79:14
277    |
278 LL |         &mut x.0; //~ ERROR
279    |              ^^^ cannot mutably borrow field of immutable binding
280
281 error[E0594]: cannot assign to immutable static item
282   --> $DIR/mutability-errors.rs:86:5
283    |
284 LL |     X = (1,); //~ ERROR
285    |     ^^^^^^^^
286
287 error[E0594]: cannot assign to field of immutable binding
288   --> $DIR/mutability-errors.rs:87:5
289    |
290 LL |     X.0 = 1; //~ ERROR
291    |     ^^^^^^^ cannot mutably borrow field of immutable binding
292
293 error[E0596]: cannot borrow immutable static item as mutable
294   --> $DIR/mutability-errors.rs:88:10
295    |
296 LL |     &mut X; //~ ERROR
297    |          ^
298
299 error[E0596]: cannot borrow field of immutable binding as mutable
300   --> $DIR/mutability-errors.rs:89:10
301    |
302 LL |     &mut X.0; //~ ERROR
303    |          ^^^ cannot mutably borrow field of immutable binding
304
305 error: aborting due to 35 previous errors
306
307 Some errors occurred: E0387, E0594, E0595, E0596.
308 For more information about an error, try `rustc --explain E0387`.