1 error[E0594]: cannot assign to `x`, as it is a captured variable in a `Fn` closure
2 --> $DIR/borrow-immutable-upvar-mutation.rs:21:27
4 LL | fn to_fn<A, F: Fn<A>>(f: F) -> F {
5 | - change this to accept `FnMut` instead of `Fn`
7 LL | let _f = to_fn(|| x = 42);
8 | ----- ^^^^^^ cannot assign
10 | expects `Fn` instead of `FnMut`
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:24:31
15 LL | fn to_fn<A, F: Fn<A>>(f: F) -> F {
16 | - change this to accept `FnMut` instead of `Fn`
18 LL | let _g = to_fn(|| set(&mut y));
19 | ----- ^^^^^^ cannot borrow as mutable
21 | expects `Fn` instead of `FnMut`
23 error[E0594]: cannot assign to `z`, as it is a captured variable in a `Fn` closure
24 --> $DIR/borrow-immutable-upvar-mutation.rs:29:22
26 LL | fn to_fn<A, F: Fn<A>>(f: F) -> F {
27 | - change this to accept `FnMut` instead of `Fn`
29 LL | to_fn(|| z = 42);
30 | ----- ^^^^^^ cannot assign
32 | expects `Fn` instead of `FnMut`
34 error[E0594]: cannot assign to `x`, as it is a captured variable in a `Fn` closure
35 --> $DIR/borrow-immutable-upvar-mutation.rs:36:32
37 LL | fn to_fn<A, F: Fn<A>>(f: F) -> F {
38 | - change this to accept `FnMut` instead of `Fn`
40 LL | let _f = to_fn(move || x = 42);
41 | ----- ^^^^^^ cannot assign
43 | expects `Fn` instead of `FnMut`
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:39:36
48 LL | fn to_fn<A, F: Fn<A>>(f: F) -> F {
49 | - change this to accept `FnMut` instead of `Fn`
51 LL | let _g = to_fn(move || set(&mut y));
52 | ----- ^^^^^^ cannot borrow as mutable
54 | expects `Fn` instead of `FnMut`
56 error[E0594]: cannot assign to `z`, as it is a captured variable in a `Fn` closure
57 --> $DIR/borrow-immutable-upvar-mutation.rs:44:27
59 LL | fn to_fn<A, F: Fn<A>>(f: F) -> F {
60 | - change this to accept `FnMut` instead of `Fn`
62 LL | to_fn(move || z = 42);
63 | ----- ^^^^^^ cannot assign
65 | expects `Fn` instead of `FnMut`
67 error[E0594]: cannot assign to `x`, as it is a captured variable in a `Fn` closure
68 --> $DIR/borrow-immutable-upvar-mutation.rs:53:9
70 LL | fn foo() -> Box<dyn Fn() -> usize> {
71 | --- ---------------------- change this to return `FnMut` instead of `Fn`
73 LL | Box::new(move || {
76 | | ^^^^^^ cannot assign
79 | |_____- in this closure
81 error: aborting due to 7 previous errors
83 Some errors have detailed explanations: E0594, E0596.
84 For more information about an error, try `rustc --explain E0594`.