fork/rust

git clone https://git.julia.blue/fork/rust

borsAuto merge of #103046 - JanBeh:PR_clarify_cmp_terminology, r=workingjubilee3bcad65fbf6

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