]>
Commit | Line | Data |
---|---|---|
dfeec247 XL |
1 | error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable |
2 | --> $DIR/borrow-raw-address-of-mutability.rs:5:13 | |
3 | | | |
4 | LL | let x = 0; | |
5 | | - help: consider changing this to be mutable: `mut x` | |
6 | LL | let y = &raw mut x; | |
7 | | ^^^^^^^^^^ cannot borrow as mutable | |
8 | ||
9 | error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable | |
10 | --> $DIR/borrow-raw-address-of-mutability.rs:11:17 | |
11 | | | |
12 | LL | let x = 0; | |
13 | | - help: consider changing this to be mutable: `mut x` | |
14 | LL | let mut f = || { | |
15 | LL | let y = &raw mut x; | |
16 | | ^^^^^^^^^^ cannot borrow as mutable | |
17 | ||
18 | error[E0596]: cannot borrow `f` as mutable, as it is not declared as mutable | |
19 | --> $DIR/borrow-raw-address-of-mutability.rs:21:5 | |
20 | | | |
21 | LL | let f = || { | |
22 | | - help: consider changing this to be mutable: `mut f` | |
5869c6ff XL |
23 | LL | let y = &raw mut x; |
24 | | - calling `f` requires mutable binding due to mutable borrow of `x` | |
25 | LL | }; | |
dfeec247 XL |
26 | LL | f(); |
27 | | ^ cannot borrow as mutable | |
28 | ||
29 | error[E0596]: cannot borrow `x` as mutable, as it is a captured variable in a `Fn` closure | |
30 | --> $DIR/borrow-raw-address-of-mutability.rs:29:17 | |
31 | | | |
064997fb FG |
32 | LL | fn make_fn<F: Fn()>(f: F) -> F { f } |
33 | | - change this to accept `FnMut` instead of `Fn` | |
74b04a01 | 34 | ... |
064997fb FG |
35 | LL | let f = make_fn(|| { |
36 | | ------- -- in this closure | |
37 | | | | |
38 | | expects `Fn` instead of `FnMut` | |
39 | LL | let y = &raw mut x; | |
40 | | ^^^^^^^^^^ cannot borrow as mutable | |
dfeec247 XL |
41 | |
42 | error[E0596]: cannot borrow `x` as mutable, as it is a captured variable in a `Fn` closure | |
43 | --> $DIR/borrow-raw-address-of-mutability.rs:37:17 | |
44 | | | |
064997fb FG |
45 | LL | fn make_fn<F: Fn()>(f: F) -> F { f } |
46 | | - change this to accept `FnMut` instead of `Fn` | |
74b04a01 | 47 | ... |
064997fb FG |
48 | LL | let f = make_fn(move || { |
49 | | ------- ------- in this closure | |
50 | | | | |
51 | | expects `Fn` instead of `FnMut` | |
52 | LL | let y = &raw mut x; | |
53 | | ^^^^^^^^^^ cannot borrow as mutable | |
dfeec247 XL |
54 | |
55 | error: aborting due to 5 previous errors | |
56 | ||
57 | For more information about this error, try `rustc --explain E0596`. |