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