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: std::marker::Tuple, 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
11 | expects `Fn` instead of `FnMut`
13 error[E0596]: cannot borrow `y` as mutable, as it is a captured variable in a `Fn` closure
14 --> $DIR/borrow-immutable-upvar-mutation.rs:24:31
16 LL | fn to_fn<A: std::marker::Tuple, F: Fn<A>>(f: F) -> F {
17 | - change this to accept `FnMut` instead of `Fn`
19 LL | let _g = to_fn(|| set(&mut y));
20 | ----- -- ^^^^^^ cannot borrow as mutable
23 | expects `Fn` instead of `FnMut`
25 error[E0594]: cannot assign to `z`, as it is a captured variable in a `Fn` closure
26 --> $DIR/borrow-immutable-upvar-mutation.rs:29:22
28 LL | fn to_fn<A: std::marker::Tuple, F: Fn<A>>(f: F) -> F {
29 | - change this to accept `FnMut` instead of `Fn`
31 LL | to_fn(|| z = 42);
32 | ----- -- ^^^^^^ cannot assign
35 | expects `Fn` instead of `FnMut`
37 error[E0594]: cannot assign to `x`, as it is a captured variable in a `Fn` closure
38 --> $DIR/borrow-immutable-upvar-mutation.rs:36:32
40 LL | fn to_fn<A: std::marker::Tuple, F: Fn<A>>(f: F) -> F {
41 | - change this to accept `FnMut` instead of `Fn`
43 LL | let _f = to_fn(move || x = 42);
44 | ----- ------- ^^^^^^ cannot assign
47 | expects `Fn` instead of `FnMut`
49 error[E0596]: cannot borrow `y` as mutable, as it is a captured variable in a `Fn` closure
50 --> $DIR/borrow-immutable-upvar-mutation.rs:39:36
52 LL | fn to_fn<A: std::marker::Tuple, F: Fn<A>>(f: F) -> F {
53 | - change this to accept `FnMut` instead of `Fn`
55 LL | let _g = to_fn(move || set(&mut y));
56 | ----- ------- ^^^^^^ cannot borrow as mutable
59 | expects `Fn` instead of `FnMut`
61 error[E0594]: cannot assign to `z`, as it is a captured variable in a `Fn` closure
62 --> $DIR/borrow-immutable-upvar-mutation.rs:44:27
64 LL | fn to_fn<A: std::marker::Tuple, F: Fn<A>>(f: F) -> F {
65 | - change this to accept `FnMut` instead of `Fn`
67 LL | to_fn(move || z = 42);
68 | ----- ------- ^^^^^^ cannot assign
71 | expects `Fn` instead of `FnMut`
73 error[E0594]: cannot assign to `x`, as it is a captured variable in a `Fn` closure
74 --> $DIR/borrow-immutable-upvar-mutation.rs:53:9
76 LL | fn foo() -> Box<dyn Fn() -> usize> {
77 | --- ---------------------- change this to return `FnMut` instead of `Fn`
79 LL | Box::new(move || {
80 | ------- in this closure
82 | ^^^^^^ cannot assign
84 error: aborting due to 7 previous errors
86 Some errors have detailed explanations: E0594, E0596.
87 For more information about an error, try `rustc --explain E0594`.