fork/rust

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

borsAuto merge of #69444 - pietroalbini:stable-next-final-v2-new, r=pietroalbinif3e1a954d2e

1.41.1
2.2 KiB53 linesraw
1error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable
2  --> $DIR/borrowck-access-permissions.rs:9:19
3   |
4LL |     let x = 1;
5   |         - help: consider changing this to be mutable: `mut x`
6...
7LL |         let _y1 = &mut x;
8   |                   ^^^^^^ cannot borrow as mutable
9
10error[E0596]: cannot borrow immutable static item `static_x` as mutable
11  --> $DIR/borrowck-access-permissions.rs:14:19
12   |
13LL |         let _y1 = &mut static_x;
14   |                   ^^^^^^^^^^^^^ cannot borrow as mutable
15
16error[E0596]: cannot borrow `*box_x` as mutable, as `box_x` is not declared as mutable
17  --> $DIR/borrowck-access-permissions.rs:22:19
18   |
19LL |         let box_x = Box::new(1);
20   |             ----- help: consider changing this to be mutable: `mut box_x`
21...
22LL |         let _y1 = &mut *box_x;
23   |                   ^^^^^^^^^^^ cannot borrow as mutable
24
25error[E0596]: cannot borrow `*ref_x` as mutable, as it is behind a `&` reference
26  --> $DIR/borrowck-access-permissions.rs:30:19
27   |
28LL |         let ref_x = &x;
29   |                     -- help: consider changing this to be a mutable reference: `&mut x`
30...
31LL |         let _y1 = &mut *ref_x;
32   |                   ^^^^^^^^^^^ `ref_x` is a `&` reference, so the data it refers to cannot be borrowed as mutable
33
34error[E0596]: cannot borrow `*ptr_x` as mutable, as it is behind a `*const` pointer
35  --> $DIR/borrowck-access-permissions.rs:39:23
36   |
37LL |         let ptr_x : *const _ = &x;
38   |                                -- help: consider changing this to be a mutable pointer: `&mut x`
39...
40LL |             let _y1 = &mut *ptr_x;
41   |                       ^^^^^^^^^^^ `ptr_x` is a `*const` pointer, so the data it refers to cannot be borrowed as mutable
42
43error[E0596]: cannot borrow `*foo_ref.f` as mutable, as it is behind a `&` reference
44  --> $DIR/borrowck-access-permissions.rs:48:18
45   |
46LL |         let foo_ref = &foo;
47   |                       ---- help: consider changing this to be a mutable reference: `&mut foo`
48LL |         let _y = &mut *foo_ref.f;
49   |                  ^^^^^^^^^^^^^^^ `foo_ref` is a `&` reference, so the data it refers to cannot be borrowed as mutable
50
51error: aborting due to 6 previous errors
52
53For more information about this error, try `rustc --explain E0596`.