@@ -14,6 +14,16 @@ LL | fn deref_extend_mut_field1(x: &Own<Point>) -> &mut isize {
14
14
LL | &mut x.y //~ ERROR cannot borrow
15
15
| ^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable
16
16
17
+ error[E0499]: cannot borrow `*x` as mutable more than once at a time
18
+ --> $DIR/borrowck-borrow-overloaded-auto-deref-mut.rs:88:19
19
+ |
20
+ LL | let _x = &mut x.x;
21
+ | - first mutable borrow occurs here
22
+ LL | let _y = &mut x.y; //~ ERROR cannot borrow
23
+ | ^ second mutable borrow occurs here
24
+ LL | use_mut(_x);
25
+ | -- first borrow later used here
26
+
17
27
error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable
18
28
--> $DIR/borrowck-borrow-overloaded-auto-deref-mut.rs:98:5
19
29
|
@@ -30,6 +40,16 @@ LL | fn assign_field2<'a>(x: &'a Own<Point>) {
30
40
LL | x.y = 3; //~ ERROR cannot borrow
31
41
| ^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable
32
42
43
+ error[E0499]: cannot borrow `*x` as mutable more than once at a time
44
+ --> $DIR/borrowck-borrow-overloaded-auto-deref-mut.rs:111:5
45
+ |
46
+ LL | let _p: &mut Point = &mut **x;
47
+ | -- first mutable borrow occurs here
48
+ LL | x.y = 3; //~ ERROR cannot borrow
49
+ | ^ second mutable borrow occurs here
50
+ LL | use_mut(_p);
51
+ | -- first borrow later used here
52
+
33
53
error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable
34
54
--> $DIR/borrowck-borrow-overloaded-auto-deref-mut.rs:119:5
35
55
|
@@ -62,6 +82,7 @@ LL | fn assign_method2<'a>(x: &'a Own<Point>) {
62
82
LL | *x.y_mut() = 3; //~ ERROR cannot borrow
63
83
| ^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable
64
84
65
- error: aborting due to 8 previous errors
85
+ error: aborting due to 10 previous errors
66
86
67
- For more information about this error, try `rustc --explain E0596`.
87
+ Some errors occurred: E0499, E0596.
88
+ For more information about an error, try `rustc --explain E0499`.
0 commit comments