fork/rust

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

borsAuto merge of #71365 - Mark-Simulacrum:stable-next, r=Mark-Simulacrum4fb7144ed15

1.43.0
5.1 KiB160 linesraw
1error[E0594]: cannot assign to `x`, as it is not declared as mutable
2  --> $DIR/closure-captures.rs:7:5
3   |
4LL | fn one_closure(x: i32) {
5   |                - help: consider changing this to be mutable: `mut x`
6LL |     ||
7LL |     x = 1;
8   |     ^^^^^ cannot assign
9
10error[E0594]: cannot assign to `x`, as it is not declared as mutable
11  --> $DIR/closure-captures.rs:9:5
12   |
13LL | fn one_closure(x: i32) {
14   |                - help: consider changing this to be mutable: `mut x`
15...
16LL |     x = 1;
17   |     ^^^^^ cannot assign
18
19error[E0594]: cannot assign to `x`, as it is not declared as mutable
20  --> $DIR/closure-captures.rs:15:9
21   |
22LL | fn two_closures(x: i32) {
23   |                 - help: consider changing this to be mutable: `mut x`
24...
25LL |         x = 1;
26   |         ^^^^^ cannot assign
27
28error[E0594]: cannot assign to `x`, as it is not declared as mutable
29  --> $DIR/closure-captures.rs:19:9
30   |
31LL | fn two_closures(x: i32) {
32   |                 - help: consider changing this to be mutable: `mut x`
33...
34LL |         x = 1;
35   |         ^^^^^ cannot assign
36
37error[E0596]: cannot borrow `x` as mutable, as it is a captured variable in a `Fn` closure
38  --> $DIR/closure-captures.rs:27:9
39   |
40LL |   fn fn_ref<F: Fn()>(f: F) -> F { f }
41   |                         - change this to accept `FnMut` instead of `Fn`
42...
43LL |       fn_ref(|| {
44   |  _____------_-
45   | |     |
46   | |     expects `Fn` instead of `FnMut`
47LL | |         ||
48   | |         ^^ cannot borrow as mutable
49LL | |          x = 1;}
50   | |__________-_____- in this closure
51   |            |
52   |            mutable borrow occurs due to use of `x` in closure
53
54error[E0596]: cannot borrow `x` as mutable, as it is a captured variable in a `Fn` closure
55  --> $DIR/closure-captures.rs:31:9
56   |
57LL |   fn fn_ref<F: Fn()>(f: F) -> F { f }
58   |                         - change this to accept `FnMut` instead of `Fn`
59...
60LL |       fn_ref(move || {
61   |  _____------_-
62   | |     |
63   | |     expects `Fn` instead of `FnMut`
64LL | |         ||
65   | |         ^^ cannot borrow as mutable
66LL | |     x = 1;});
67   | |_____-_____- in this closure
68   |       |
69   |       mutable borrow occurs due to use of `x` in closure
70
71error[E0594]: cannot assign to `x`, as it is not declared as mutable
72  --> $DIR/closure-captures.rs:39:10
73   |
74LL | fn two_closures_ref(x: i32) {
75   |                     - help: consider changing this to be mutable: `mut x`
76...
77LL |          x = 1;}
78   |          ^^^^^ cannot assign
79
80error[E0596]: cannot borrow `x` as mutable, as it is a captured variable in a `Fn` closure
81  --> $DIR/closure-captures.rs:38:9
82   |
83LL |   fn fn_ref<F: Fn()>(f: F) -> F { f }
84   |                         - change this to accept `FnMut` instead of `Fn`
85...
86LL |       fn_ref(|| {
87   |  _____------_-
88   | |     |
89   | |     expects `Fn` instead of `FnMut`
90LL | |         ||
91   | |         ^^ cannot borrow as mutable
92LL | |          x = 1;}
93   | |__________-_____- in this closure
94   |            |
95   |            mutable borrow occurs due to use of `x` in closure
96
97error[E0594]: cannot assign to `x`, as it is not declared as mutable
98  --> $DIR/closure-captures.rs:43:5
99   |
100LL | fn two_closures_ref(x: i32) {
101   |                     - help: consider changing this to be mutable: `mut x`
102...
103LL |     x = 1;});
104   |     ^^^^^ cannot assign
105
106error[E0596]: cannot borrow `x` as mutable, as it is a captured variable in a `Fn` closure
107  --> $DIR/closure-captures.rs:42:9
108   |
109LL |   fn fn_ref<F: Fn()>(f: F) -> F { f }
110   |                         - change this to accept `FnMut` instead of `Fn`
111...
112LL |       fn_ref(move || {
113   |  _____------_-
114   | |     |
115   | |     expects `Fn` instead of `FnMut`
116LL | |         ||
117   | |         ^^ cannot borrow as mutable
118LL | |     x = 1;});
119   | |_____-_____- in this closure
120   |       |
121   |       mutable borrow occurs due to use of `x` in closure
122
123error[E0596]: cannot borrow `x` as mutable, as it is a captured variable in a `Fn` closure
124  --> $DIR/closure-captures.rs:48:9
125   |
126LL |   fn fn_ref<F: Fn()>(f: F) -> F { f }
127   |                         - change this to accept `FnMut` instead of `Fn`
128...
129LL |       fn_ref(|| {
130   |  _____------_-
131   | |     |
132   | |     expects `Fn` instead of `FnMut`
133LL | |         ||
134   | |         ^^ cannot borrow as mutable
135LL | |         *x = 1;});
136   | |__________-_____- in this closure
137   |            |
138   |            mutable borrow occurs due to use of `x` in closure
139
140error[E0596]: cannot borrow `x` as mutable, as it is a captured variable in a `Fn` closure
141  --> $DIR/closure-captures.rs:51:9
142   |
143LL |   fn fn_ref<F: Fn()>(f: F) -> F { f }
144   |                         - change this to accept `FnMut` instead of `Fn`
145...
146LL |       fn_ref(move || {
147   |  _____------_-
148   | |     |
149   | |     expects `Fn` instead of `FnMut`
150LL | |         ||
151   | |         ^^ cannot borrow as mutable
152LL | |         *x = 1;});
153   | |__________-_____- in this closure
154   |            |
155   |            mutable borrow occurs due to use of `x` in closure
156
157error: aborting due to 12 previous errors
158
159Some errors have detailed explanations: E0594, E0596.
160For more information about an error, try `rustc --explain E0594`.