summary refs log tree commit diff
path: root/src/test/ui/borrowck/borrow-immutable-upvar-mutation.stderr
blob: a28cb7431e6a905abc07ab71dc3b8330279fff41 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
error[E0594]: cannot assign to `x`, as it is a captured variable in a `Fn` closure
  --> $DIR/borrow-immutable-upvar-mutation.rs:21:27
   |
LL | fn to_fn<A, F: Fn<A>>(f: F) -> F {
   |                          - change this to accept `FnMut` instead of `Fn`
...
LL |         let _f = to_fn(|| x = 42);
   |                  -----    ^^^^^^ cannot assign
   |                  |
   |                  expects `Fn` instead of `FnMut`

error[E0596]: cannot borrow `y` as mutable, as it is a captured variable in a `Fn` closure
  --> $DIR/borrow-immutable-upvar-mutation.rs:24:31
   |
LL | fn to_fn<A, F: Fn<A>>(f: F) -> F {
   |                          - change this to accept `FnMut` instead of `Fn`
...
LL |         let _g = to_fn(|| set(&mut y));
   |                  -----        ^^^^^^ cannot borrow as mutable
   |                  |
   |                  expects `Fn` instead of `FnMut`

error[E0594]: cannot assign to `z`, as it is a captured variable in a `Fn` closure
  --> $DIR/borrow-immutable-upvar-mutation.rs:29:22
   |
LL | fn to_fn<A, F: Fn<A>>(f: F) -> F {
   |                          - change this to accept `FnMut` instead of `Fn`
...
LL |             to_fn(|| z = 42);
   |             -----    ^^^^^^ cannot assign
   |             |
   |             expects `Fn` instead of `FnMut`

error[E0594]: cannot assign to `x`, as it is a captured variable in a `Fn` closure
  --> $DIR/borrow-immutable-upvar-mutation.rs:36:32
   |
LL | fn to_fn<A, F: Fn<A>>(f: F) -> F {
   |                          - change this to accept `FnMut` instead of `Fn`
...
LL |         let _f = to_fn(move || x = 42);
   |                  -----         ^^^^^^ cannot assign
   |                  |
   |                  expects `Fn` instead of `FnMut`

error[E0596]: cannot borrow `y` as mutable, as it is a captured variable in a `Fn` closure
  --> $DIR/borrow-immutable-upvar-mutation.rs:39:36
   |
LL | fn to_fn<A, F: Fn<A>>(f: F) -> F {
   |                          - change this to accept `FnMut` instead of `Fn`
...
LL |         let _g = to_fn(move || set(&mut y));
   |                  -----             ^^^^^^ cannot borrow as mutable
   |                  |
   |                  expects `Fn` instead of `FnMut`

error[E0594]: cannot assign to `z`, as it is a captured variable in a `Fn` closure
  --> $DIR/borrow-immutable-upvar-mutation.rs:44:27
   |
LL | fn to_fn<A, F: Fn<A>>(f: F) -> F {
   |                          - change this to accept `FnMut` instead of `Fn`
...
LL |             to_fn(move || z = 42);
   |             -----         ^^^^^^ cannot assign
   |             |
   |             expects `Fn` instead of `FnMut`

error[E0594]: cannot assign to `x`, as it is a captured variable in a `Fn` closure
  --> $DIR/borrow-immutable-upvar-mutation.rs:53:9
   |
LL |   fn foo() -> Box<dyn Fn() -> usize> {
   |      ---      ---------------------- change this to return `FnMut` instead of `Fn`
LL |       let mut x = 0;
LL |       Box::new(move || {
   |  ______________-
LL | |         x += 1;
   | |         ^^^^^^ cannot assign
LL | |         x
LL | |     })
   | |_____- in this closure

error: aborting due to 7 previous errors

Some errors have detailed explanations: E0594, E0596.
For more information about an error, try `rustc --explain E0594`.