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