fork/rust

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

borsAuto merge of #68568 - pietroalbini:stable-next, r=pietroalbini5e1a799842b

1.41.0
3.9 KiB88 linesraw
1error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable
2  --> $DIR/borrowck-borrow-overloaded-auto-deref-mut.rs:53:24
3   |
4LL | fn deref_mut_field1(x: Own<Point>) {
5   |                     - help: consider changing this to be mutable: `mut x`
6LL |     let __isize = &mut x.y;
7   |                        ^ cannot borrow as mutable
8
9error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference
10  --> $DIR/borrowck-borrow-overloaded-auto-deref-mut.rs:65:10
11   |
12LL | fn deref_extend_mut_field1(x: &Own<Point>) -> &mut isize {
13   |                               ----------- help: consider changing this to be a mutable reference: `&mut Own<Point>`
14LL |     &mut x.y
15   |          ^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable
16
17error[E0499]: cannot borrow `*x` as mutable more than once at a time
18  --> $DIR/borrowck-borrow-overloaded-auto-deref-mut.rs:78:19
19   |
20LL |     let _x = &mut x.x;
21   |                   - first mutable borrow occurs here
22LL |     let _y = &mut x.y;
23   |                   ^ second mutable borrow occurs here
24LL |     use_mut(_x);
25   |             -- first borrow later used here
26
27error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable
28  --> $DIR/borrowck-borrow-overloaded-auto-deref-mut.rs:88:5
29   |
30LL | fn assign_field1<'a>(x: Own<Point>) {
31   |                      - help: consider changing this to be mutable: `mut x`
32LL |     x.y = 3;
33   |     ^ cannot borrow as mutable
34
35error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference
36  --> $DIR/borrowck-borrow-overloaded-auto-deref-mut.rs:92:5
37   |
38LL | fn assign_field2<'a>(x: &'a Own<Point>) {
39   |                         -------------- help: consider changing this to be a mutable reference: `&'a mut Own<Point>`
40LL |     x.y = 3;
41   |     ^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable
42
43error[E0499]: cannot borrow `*x` as mutable more than once at a time
44  --> $DIR/borrowck-borrow-overloaded-auto-deref-mut.rs:101:5
45   |
46LL |     let _p: &mut Point = &mut **x;
47   |                                -- first mutable borrow occurs here
48LL |     x.y = 3;
49   |     ^ second mutable borrow occurs here
50LL |     use_mut(_p);
51   |             -- first borrow later used here
52
53error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable
54  --> $DIR/borrowck-borrow-overloaded-auto-deref-mut.rs:109:5
55   |
56LL | fn deref_mut_method1(x: Own<Point>) {
57   |                      - help: consider changing this to be mutable: `mut x`
58LL |     x.set(0, 0);
59   |     ^ cannot borrow as mutable
60
61error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference
62  --> $DIR/borrowck-borrow-overloaded-auto-deref-mut.rs:121:5
63   |
64LL | fn deref_extend_mut_method1(x: &Own<Point>) -> &mut isize {
65   |                                ----------- help: consider changing this to be a mutable reference: `&mut Own<Point>`
66LL |     x.y_mut()
67   |     ^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable
68
69error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable
70  --> $DIR/borrowck-borrow-overloaded-auto-deref-mut.rs:129:6
71   |
72LL | fn assign_method1<'a>(x: Own<Point>) {
73   |                       - help: consider changing this to be mutable: `mut x`
74LL |     *x.y_mut() = 3;
75   |      ^ cannot borrow as mutable
76
77error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference
78  --> $DIR/borrowck-borrow-overloaded-auto-deref-mut.rs:133:6
79   |
80LL | fn assign_method2<'a>(x: &'a Own<Point>) {
81   |                          -------------- help: consider changing this to be a mutable reference: `&'a mut Own<Point>`
82LL |     *x.y_mut() = 3;
83   |      ^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable
84
85error: aborting due to 10 previous errors
86
87Some errors have detailed explanations: E0499, E0596.
88For more information about an error, try `rustc --explain E0499`.