1
1
error[E0594]: cannot assign to `x`, as it is a captured variable in a `Fn` closure
2
- --> $DIR/borrow-immutable-upvar-mutation.rs:15 :27
2
+ --> $DIR/borrow-immutable-upvar-mutation.rs:21 :27
3
3
|
4
- LL | fn to_fn<A,F: Fn<A>>(f: F) -> F { f }
5
- | - change this to accept `FnMut` instead of `Fn`
4
+ LL | fn to_fn<A, F: Fn<A>>(f: F) -> F {
5
+ | - change this to accept `FnMut` instead of `Fn`
6
6
...
7
7
LL | let _f = to_fn(|| x = 42);
8
8
| ----- ^^^^^^ cannot assign
9
9
| |
10
10
| expects `Fn` instead of `FnMut`
11
11
12
12
error[E0596]: cannot borrow `y` as mutable, as it is a captured variable in a `Fn` closure
13
- --> $DIR/borrow-immutable-upvar-mutation.rs:18 :31
13
+ --> $DIR/borrow-immutable-upvar-mutation.rs:24 :31
14
14
|
15
- LL | fn to_fn<A,F: Fn<A>>(f: F) -> F { f }
16
- | - change this to accept `FnMut` instead of `Fn`
15
+ LL | fn to_fn<A, F: Fn<A>>(f: F) -> F {
16
+ | - change this to accept `FnMut` instead of `Fn`
17
17
...
18
18
LL | let _g = to_fn(|| set(&mut y));
19
19
| ----- ^^^^^^ cannot borrow as mutable
20
20
| |
21
21
| expects `Fn` instead of `FnMut`
22
22
23
23
error[E0594]: cannot assign to `z`, as it is a captured variable in a `Fn` closure
24
- --> $DIR/borrow-immutable-upvar-mutation.rs:23 :22
24
+ --> $DIR/borrow-immutable-upvar-mutation.rs:29 :22
25
25
|
26
- LL | fn to_fn<A,F: Fn<A>>(f: F) -> F { f }
27
- | - change this to accept `FnMut` instead of `Fn`
26
+ LL | fn to_fn<A, F: Fn<A>>(f: F) -> F {
27
+ | - change this to accept `FnMut` instead of `Fn`
28
28
...
29
29
LL | to_fn(|| z = 42);
30
30
| ----- ^^^^^^ cannot assign
31
31
| |
32
32
| expects `Fn` instead of `FnMut`
33
33
34
34
error[E0594]: cannot assign to `x`, as it is a captured variable in a `Fn` closure
35
- --> $DIR/borrow-immutable-upvar-mutation.rs:30 :32
35
+ --> $DIR/borrow-immutable-upvar-mutation.rs:36 :32
36
36
|
37
- LL | fn to_fn<A,F: Fn<A>>(f: F) -> F { f }
38
- | - change this to accept `FnMut` instead of `Fn`
37
+ LL | fn to_fn<A, F: Fn<A>>(f: F) -> F {
38
+ | - change this to accept `FnMut` instead of `Fn`
39
39
...
40
40
LL | let _f = to_fn(move || x = 42);
41
41
| ----- ^^^^^^ cannot assign
42
42
| |
43
43
| expects `Fn` instead of `FnMut`
44
44
45
45
error[E0596]: cannot borrow `y` as mutable, as it is a captured variable in a `Fn` closure
46
- --> $DIR/borrow-immutable-upvar-mutation.rs:33 :36
46
+ --> $DIR/borrow-immutable-upvar-mutation.rs:39 :36
47
47
|
48
- LL | fn to_fn<A,F: Fn<A>>(f: F) -> F { f }
49
- | - change this to accept `FnMut` instead of `Fn`
48
+ LL | fn to_fn<A, F: Fn<A>>(f: F) -> F {
49
+ | - change this to accept `FnMut` instead of `Fn`
50
50
...
51
51
LL | let _g = to_fn(move || set(&mut y));
52
52
| ----- ^^^^^^ cannot borrow as mutable
53
53
| |
54
54
| expects `Fn` instead of `FnMut`
55
55
56
56
error[E0594]: cannot assign to `z`, as it is a captured variable in a `Fn` closure
57
- --> $DIR/borrow-immutable-upvar-mutation.rs:36:65
57
+ --> $DIR/borrow-immutable-upvar-mutation.rs:44:27
58
58
|
59
- LL | fn to_fn<A,F: Fn<A>>(f: F) -> F { f }
60
- | - change this to accept `FnMut` instead of `Fn`
59
+ LL | fn to_fn<A, F: Fn<A>>(f: F) -> F {
60
+ | - change this to accept `FnMut` instead of `Fn`
61
61
...
62
- LL | let _h = to_fn_mut(move || { set(&mut z); to_fn(move || z = 42); } );
63
- | ----- ^^^^^^ cannot assign
64
- | |
65
- | expects `Fn` instead of `FnMut`
62
+ LL | to_fn(move || z = 42);
63
+ | ----- ^^^^^^ cannot assign
64
+ | |
65
+ | expects `Fn` instead of `FnMut`
66
66
67
67
error[E0594]: cannot assign to `x`, as it is a captured variable in a `Fn` closure
68
- --> $DIR/borrow-immutable-upvar-mutation.rs:43 :9
68
+ --> $DIR/borrow-immutable-upvar-mutation.rs:53 :9
69
69
|
70
70
LL | fn foo() -> Box<dyn Fn() -> usize> {
71
71
| --- ---------------------- change this to return `FnMut` instead of `Fn`
@@ -78,20 +78,7 @@ LL | | x
78
78
LL | | })
79
79
| |_____- in this closure
80
80
81
- error[E0594]: cannot assign to `x`, as it is a captured variable in a `Fn` closure
82
- --> $DIR/borrow-immutable-upvar-mutation.rs:51:9
83
- |
84
- LL | fn bar() -> impl Fn() -> usize {
85
- | --- ------------------ change this to return `FnMut` instead of `Fn`
86
- LL | let mut x = 0;
87
- LL | / move || {
88
- LL | | x += 1;
89
- | | ^^^^^^ cannot assign
90
- LL | | x
91
- LL | | }
92
- | |_____- in this closure
93
-
94
- error: aborting due to 8 previous errors
81
+ error: aborting due to 7 previous errors
95
82
96
83
Some errors have detailed explanations: E0594, E0596.
97
84
For more information about an error, try `rustc --explain E0594`.
0 commit comments