blob: 740e1820f4f3c0b2bba3aba74fee65ad1659cd95 (
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
|
error[E0387]: cannot assign to data in a captured outer variable in an `Fn` closure
--> $DIR/borrow-immutable-upvar-mutation.rs:25:27
|
LL | let _f = to_fn(|| x = 42); //~ ERROR cannot assign
| ^^^^^^
|
help: consider changing this closure to take self by mutable reference
--> $DIR/borrow-immutable-upvar-mutation.rs:25:24
|
LL | let _f = to_fn(|| x = 42); //~ ERROR cannot assign
| ^^^^^^^^^
error[E0387]: cannot borrow data mutably in a captured outer variable in an `Fn` closure
--> $DIR/borrow-immutable-upvar-mutation.rs:28:36
|
LL | let _g = to_fn(|| set(&mut y)); //~ ERROR cannot borrow
| ^
|
help: consider changing this closure to take self by mutable reference
--> $DIR/borrow-immutable-upvar-mutation.rs:28:24
|
LL | let _g = to_fn(|| set(&mut y)); //~ ERROR cannot borrow
| ^^^^^^^^^^^^^^
error[E0387]: cannot assign to data in a captured outer variable in an `Fn` closure
--> $DIR/borrow-immutable-upvar-mutation.rs:31:55
|
LL | let _h = to_fn_mut(|| { set(&mut z); to_fn(|| z = 42); }); //~ ERROR cannot assign
| ^^^^^^
|
help: consider changing this closure to take self by mutable reference
--> $DIR/borrow-immutable-upvar-mutation.rs:31:52
|
LL | let _h = to_fn_mut(|| { set(&mut z); to_fn(|| z = 42); }); //~ ERROR cannot assign
| ^^^^^^^^^
error[E0594]: cannot assign to captured outer variable in an `Fn` closure
--> $DIR/borrow-immutable-upvar-mutation.rs:37:32
|
LL | let _f = to_fn(move || x = 42); //~ ERROR cannot assign
| ^^^^^^
|
= note: `Fn` closures cannot capture their enclosing environment for modifications
help: consider changing this closure to take self by mutable reference
--> $DIR/borrow-immutable-upvar-mutation.rs:37:24
|
LL | let _f = to_fn(move || x = 42); //~ ERROR cannot assign
| ^^^^^^^^^^^^^^
error[E0596]: cannot borrow captured outer variable in an `Fn` closure as mutable
--> $DIR/borrow-immutable-upvar-mutation.rs:40:41
|
LL | let _g = to_fn(move || set(&mut y)); //~ ERROR cannot borrow
| ^
|
help: consider changing this closure to take self by mutable reference
--> $DIR/borrow-immutable-upvar-mutation.rs:40:24
|
LL | let _g = to_fn(move || set(&mut y)); //~ ERROR cannot borrow
| ^^^^^^^^^^^^^^^^^^^
error[E0594]: cannot assign to captured outer variable in an `Fn` closure
--> $DIR/borrow-immutable-upvar-mutation.rs:43:65
|
LL | let _h = to_fn_mut(move || { set(&mut z); to_fn(move || z = 42); }); //~ ERROR cannot assign
| ^^^^^^
|
= note: `Fn` closures cannot capture their enclosing environment for modifications
help: consider changing this closure to take self by mutable reference
--> $DIR/borrow-immutable-upvar-mutation.rs:43:57
|
LL | let _h = to_fn_mut(move || { set(&mut z); to_fn(move || z = 42); }); //~ ERROR cannot assign
| ^^^^^^^^^^^^^^
error: aborting due to 6 previous errors
Some errors occurred: E0387, E0594, E0596.
For more information about an error, try `rustc --explain E0387`.
|