]> git.lizzy.rs Git - rust.git/blob - src/test/ui/borrowck/borrow-raw-address-of-mutability.stderr
Rollup merge of #88090 - nbdd0121:inference, r=nikomatsakis
[rust.git] / src / test / ui / borrowck / borrow-raw-address-of-mutability.stderr
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`
23 LL |         let y = &raw mut x;
24    |                          - calling `f` requires mutable binding due to mutable borrow of `x`
25 LL |     };
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    |
32 LL |   fn make_fn<F: Fn()>(f: F) -> F { f }
33    |                          - change this to accept `FnMut` instead of `Fn`
34 ...
35 LL |       let f = make_fn(|| {
36    |  _____________-------_-
37    | |             |
38    | |             expects `Fn` instead of `FnMut`
39 LL | |         let y = &raw mut x;
40    | |                 ^^^^^^^^^^ cannot borrow as mutable
41 LL | |     });
42    | |_____- in this closure
43
44 error[E0596]: cannot borrow `x` as mutable, as it is a captured variable in a `Fn` closure
45   --> $DIR/borrow-raw-address-of-mutability.rs:37:17
46    |
47 LL |   fn make_fn<F: Fn()>(f: F) -> F { f }
48    |                          - change this to accept `FnMut` instead of `Fn`
49 ...
50 LL |       let f = make_fn(move || {
51    |  _____________-------_-
52    | |             |
53    | |             expects `Fn` instead of `FnMut`
54 LL | |         let y = &raw mut x;
55    | |                 ^^^^^^^^^^ cannot borrow as mutable
56 LL | |     });
57    | |_____- in this closure
58
59 error: aborting due to 5 previous errors
60
61 For more information about this error, try `rustc --explain E0596`.