]> git.lizzy.rs Git - rust.git/blob - tests/ui/borrowck/borrow-immutable-upvar-mutation.stderr
Rollup merge of #106726 - cmorin6:fix-comment-typos, r=Nilstrieb
[rust.git] / tests / ui / borrowck / borrow-immutable-upvar-mutation.stderr
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
3    |
4 LL | fn to_fn<A: std::marker::Tuple, F: Fn<A>>(f: F) -> F {
5    |                                              - change this to accept `FnMut` instead of `Fn`
6 ...
7 LL |         let _f = to_fn(|| x = 42);
8    |                  ----- -- ^^^^^^ cannot assign
9    |                  |     |
10    |                  |     in this closure
11    |                  expects `Fn` instead of `FnMut`
12
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
15    |
16 LL | fn to_fn<A: std::marker::Tuple, F: Fn<A>>(f: F) -> F {
17    |                                              - change this to accept `FnMut` instead of `Fn`
18 ...
19 LL |         let _g = to_fn(|| set(&mut y));
20    |                  ----- --     ^^^^^^ cannot borrow as mutable
21    |                  |     |
22    |                  |     in this closure
23    |                  expects `Fn` instead of `FnMut`
24
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
27    |
28 LL | fn to_fn<A: std::marker::Tuple, F: Fn<A>>(f: F) -> F {
29    |                                              - change this to accept `FnMut` instead of `Fn`
30 ...
31 LL |             to_fn(|| z = 42);
32    |             ----- -- ^^^^^^ cannot assign
33    |             |     |
34    |             |     in this closure
35    |             expects `Fn` instead of `FnMut`
36
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
39    |
40 LL | fn to_fn<A: std::marker::Tuple, F: Fn<A>>(f: F) -> F {
41    |                                              - change this to accept `FnMut` instead of `Fn`
42 ...
43 LL |         let _f = to_fn(move || x = 42);
44    |                  ----- ------- ^^^^^^ cannot assign
45    |                  |     |
46    |                  |     in this closure
47    |                  expects `Fn` instead of `FnMut`
48
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
51    |
52 LL | fn to_fn<A: std::marker::Tuple, F: Fn<A>>(f: F) -> F {
53    |                                              - change this to accept `FnMut` instead of `Fn`
54 ...
55 LL |         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
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
63    |
64 LL | fn to_fn<A: std::marker::Tuple, F: Fn<A>>(f: F) -> F {
65    |                                              - change this to accept `FnMut` instead of `Fn`
66 ...
67 LL |             to_fn(move || z = 42);
68    |             ----- ------- ^^^^^^ cannot assign
69    |             |     |
70    |             |     in this closure
71    |             expects `Fn` instead of `FnMut`
72
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
75    |
76 LL | fn foo() -> Box<dyn Fn() -> usize> {
77    |    ---      ---------------------- change this to return `FnMut` instead of `Fn`
78 LL |     let mut x = 0;
79 LL |     Box::new(move || {
80    |              ------- in this closure
81 LL |         x += 1;
82    |         ^^^^^^ cannot assign
83
84 error: aborting due to 7 previous errors
85
86 Some errors have detailed explanations: E0594, E0596.
87 For more information about an error, try `rustc --explain E0594`.