fork/rust

git clone https://git.julia.blue/fork/rust

borsAuto merge of #72883 - Mark-Simulacrum:stable-next, r=Mark-Simulacrum49cae55760d

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