diff --git a/src/test/ui/span/borrowck-borrow-overloaded-auto-deref-mut.nll.stderr b/src/test/ui/span/borrowck-borrow-overloaded-auto-deref-mut.nll.stderr index 4a693a3b05d4..389a1116c163 100644 --- a/src/test/ui/span/borrowck-borrow-overloaded-auto-deref-mut.nll.stderr +++ b/src/test/ui/span/borrowck-borrow-overloaded-auto-deref-mut.nll.stderr @@ -14,6 +14,16 @@ LL | fn deref_extend_mut_field1(x: &Own) -> &mut isize { LL | &mut x.y //~ ERROR cannot borrow | ^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable +error[E0499]: cannot borrow `*x` as mutable more than once at a time + --> $DIR/borrowck-borrow-overloaded-auto-deref-mut.rs:88:19 + | +LL | let _x = &mut x.x; + | - first mutable borrow occurs here +LL | let _y = &mut x.y; //~ ERROR cannot borrow + | ^ second mutable borrow occurs here +LL | use_mut(_x); + | -- first borrow later used here + error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable --> $DIR/borrowck-borrow-overloaded-auto-deref-mut.rs:98:5 | @@ -30,6 +40,16 @@ LL | fn assign_field2<'a>(x: &'a Own) { LL | x.y = 3; //~ ERROR cannot borrow | ^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable +error[E0499]: cannot borrow `*x` as mutable more than once at a time + --> $DIR/borrowck-borrow-overloaded-auto-deref-mut.rs:111:5 + | +LL | let _p: &mut Point = &mut **x; + | -- first mutable borrow occurs here +LL | x.y = 3; //~ ERROR cannot borrow + | ^ second mutable borrow occurs here +LL | use_mut(_p); + | -- first borrow later used here + error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable --> $DIR/borrowck-borrow-overloaded-auto-deref-mut.rs:119:5 | @@ -62,6 +82,7 @@ LL | fn assign_method2<'a>(x: &'a Own) { LL | *x.y_mut() = 3; //~ ERROR cannot borrow | ^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable -error: aborting due to 8 previous errors +error: aborting due to 10 previous errors -For more information about this error, try `rustc --explain E0596`. +Some errors occurred: E0499, E0596. +For more information about an error, try `rustc --explain E0499`. diff --git a/src/test/ui/span/borrowck-borrow-overloaded-auto-deref-mut.rs b/src/test/ui/span/borrowck-borrow-overloaded-auto-deref-mut.rs index 764d05be879b..48eb2e239f7c 100644 --- a/src/test/ui/span/borrowck-borrow-overloaded-auto-deref-mut.rs +++ b/src/test/ui/span/borrowck-borrow-overloaded-auto-deref-mut.rs @@ -86,8 +86,8 @@ fn deref_extend_mut_field3(x: &mut Own) { let _x = &mut x.x; let _y = &mut x.y; //~ ERROR cannot borrow + use_mut(_x); } - fn deref_extend_mut_field4<'a>(x: &'a mut Own) { let p = &mut **x; let _x = &mut p.x; @@ -109,8 +109,8 @@ fn assign_field3<'a>(x: &'a mut Own) { fn assign_field4<'a>(x: &'a mut Own) { let _p: &mut Point = &mut **x; x.y = 3; //~ ERROR cannot borrow + use_mut(_p); } - fn deref_imm_method(x: Own) { let __isize = x.get(); } @@ -148,3 +148,5 @@ fn assign_method3<'a>(x: &'a mut Own) { } pub fn main() {} + +fn use_mut(_: &mut T) {} diff --git a/src/test/ui/span/borrowck-borrow-overloaded-auto-deref-mut.stderr b/src/test/ui/span/borrowck-borrow-overloaded-auto-deref-mut.stderr index d91ff6964237..864357fee9f0 100644 --- a/src/test/ui/span/borrowck-borrow-overloaded-auto-deref-mut.stderr +++ b/src/test/ui/span/borrowck-borrow-overloaded-auto-deref-mut.stderr @@ -21,6 +21,7 @@ LL | let _x = &mut x.x; | - first mutable borrow occurs here LL | let _y = &mut x.y; //~ ERROR cannot borrow | ^ second mutable borrow occurs here +LL | use_mut(_x); LL | } | - first borrow ends here @@ -47,6 +48,7 @@ LL | let _p: &mut Point = &mut **x; | -- first mutable borrow occurs here LL | x.y = 3; //~ ERROR cannot borrow | ^ second mutable borrow occurs here +LL | use_mut(_p); LL | } | - first borrow ends here