]> git.lizzy.rs Git - rust.git/blob - tests/ui/borrowck/borrow-raw-address-of-mutability.stderr
Rollup merge of #106427 - mejrs:translation_errors, r=davidtwco
[rust.git] / tests / 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 y = &raw mut x;
5    |             ^^^^^^^^^^ cannot borrow as mutable
6    |
7 help: consider changing this to be mutable
8    |
9 LL |     let mut x = 0;
10    |         +++
11
12 error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable
13   --> $DIR/borrow-raw-address-of-mutability.rs:11:17
14    |
15 LL |     let x = 0;
16    |         - help: consider changing this to be mutable: `mut x`
17 LL |     let mut f = || {
18 LL |         let y = &raw mut x;
19    |                 ^^^^^^^^^^ cannot borrow as mutable
20
21 error[E0596]: cannot borrow `f` as mutable, as it is not declared as mutable
22   --> $DIR/borrow-raw-address-of-mutability.rs:21:5
23    |
24 LL |         let y = &raw mut x;
25    |                          - calling `f` requires mutable binding due to mutable borrow of `x`
26 LL |     };
27 LL |     f();
28    |     ^ cannot borrow as mutable
29    |
30 help: consider changing this to be mutable
31    |
32 LL |     let mut f = || {
33    |         +++
34
35 error[E0596]: cannot borrow `x` as mutable, as it is a captured variable in a `Fn` closure
36   --> $DIR/borrow-raw-address-of-mutability.rs:29:17
37    |
38 LL | fn make_fn<F: Fn()>(f: F) -> F { f }
39    |                        - change this to accept `FnMut` instead of `Fn`
40 ...
41 LL |     let f = make_fn(|| {
42    |             ------- -- in this closure
43    |             |
44    |             expects `Fn` instead of `FnMut`
45 LL |         let y = &raw mut x;
46    |                 ^^^^^^^^^^ cannot borrow as mutable
47
48 error[E0596]: cannot borrow `x` as mutable, as it is a captured variable in a `Fn` closure
49   --> $DIR/borrow-raw-address-of-mutability.rs:37:17
50    |
51 LL | fn make_fn<F: Fn()>(f: F) -> F { f }
52    |                        - change this to accept `FnMut` instead of `Fn`
53 ...
54 LL |     let f = make_fn(move || {
55    |             ------- ------- in this closure
56    |             |
57    |             expects `Fn` instead of `FnMut`
58 LL |         let y = &raw mut x;
59    |                 ^^^^^^^^^^ cannot borrow as mutable
60
61 error: aborting due to 5 previous errors
62
63 For more information about this error, try `rustc --explain E0596`.