]> git.lizzy.rs Git - rust.git/blob - src/test/ui/borrowck/borrow-immutable-upvar-mutation.stderr
3b06ed5e80580587f268b02b7c1174616d308356
[rust.git] / src / test / 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, 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    |                  expects `Fn` instead of `FnMut`
11
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
14    |
15 LL | fn to_fn<A, F: Fn<A>>(f: F) -> F {
16    |                          - change this to accept `FnMut` instead of `Fn`
17 ...
18 LL |         let _g = to_fn(|| set(&mut y));
19    |                  -----        ^^^^^^ cannot borrow as mutable
20    |                  |
21    |                  expects `Fn` instead of `FnMut`
22
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
25    |
26 LL | fn to_fn<A, F: Fn<A>>(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`
33
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
36    |
37 LL | fn to_fn<A, F: Fn<A>>(f: F) -> F {
38    |                          - change this to accept `FnMut` instead of `Fn`
39 ...
40 LL |         let _f = to_fn(move || x = 42);
41    |                  -----         ^^^^^^ cannot assign
42    |                  |
43    |                  expects `Fn` instead of `FnMut`
44
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
47    |
48 LL | fn to_fn<A, F: Fn<A>>(f: F) -> F {
49    |                          - change this to accept `FnMut` instead of `Fn`
50 ...
51 LL |         let _g = to_fn(move || set(&mut y));
52    |                  -----             ^^^^^^ cannot borrow as mutable
53    |                  |
54    |                  expects `Fn` instead of `FnMut`
55
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
58    |
59 LL | fn to_fn<A, F: Fn<A>>(f: F) -> F {
60    |                          - change this to accept `FnMut` instead of `Fn`
61 ...
62 LL |             to_fn(move || z = 42);
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:53:9
69    |
70 LL | fn foo() -> Box<dyn Fn() -> usize> {
71    |    ---      ---------------------- change this to return `FnMut` instead of `Fn`
72 LL |     let mut x = 0;
73 LL |     Box::new(move || {
74    |              ------- in this closure
75 LL |         x += 1;
76    |         ^^^^^^ cannot assign
77
78 error: aborting due to 7 previous errors
79
80 Some errors have detailed explanations: E0594, E0596.
81 For more information about an error, try `rustc --explain E0594`.