11error[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
33 |
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`
66...
77LL | let _f = to_fn(|| x = 42);
88 | ----- ^^^^^^ cannot assign
99 | |
1010 | expects `Fn` instead of `FnMut`
1111
1212error[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
1414 |
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`
1717...
1818LL | let _g = to_fn(|| set(&mut y));
1919 | ----- ^^^^^^ cannot borrow as mutable
2020 | |
2121 | expects `Fn` instead of `FnMut`
2222
2323error[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
2525 |
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`
2828...
2929LL | to_fn(|| z = 42);
3030 | ----- ^^^^^^ cannot assign
3131 | |
3232 | expects `Fn` instead of `FnMut`
3333
3434error[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
3636 |
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`
3939...
4040LL | let _f = to_fn(move || x = 42);
4141 | ----- ^^^^^^ cannot assign
4242 | |
4343 | expects `Fn` instead of `FnMut`
4444
4545error[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
4747 |
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`
5050...
5151LL | let _g = to_fn(move || set(&mut y));
5252 | ----- ^^^^^^ cannot borrow as mutable
5353 | |
5454 | expects `Fn` instead of `FnMut`
5555
5656error[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
5858 |
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`
6161...
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`
6666
6767error[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
6969 |
7070LL | fn foo() -> Box<dyn Fn() -> usize> {
7171 | --- ---------------------- change this to return `FnMut` instead of `Fn`
@@ -78,20 +78,7 @@ LL | | x
7878LL | | })
7979 | |_____- in this closure
8080
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
9582
9683Some errors have detailed explanations: E0594, E0596.
9784For more information about an error, try `rustc --explain E0594`.
0 commit comments