diff options
| -rw-r--r-- | src/test/ui/binop/binop-move-semantics.nll.stderr | 27 | ||||
| -rw-r--r-- | src/test/ui/binop/binop-move-semantics.rs | 7 |
2 files changed, 30 insertions, 4 deletions
diff --git a/src/test/ui/binop/binop-move-semantics.nll.stderr b/src/test/ui/binop/binop-move-semantics.nll.stderr index 545a60f6770..612375f9047 100644 --- a/src/test/ui/binop/binop-move-semantics.nll.stderr +++ b/src/test/ui/binop/binop-move-semantics.nll.stderr @@ -20,6 +20,29 @@ LL | x.clone(); //~ ERROR: use of moved value | = note: move occurs because `x` has type `T`, which does not implement the `Copy` trait +error[E0505]: cannot move out of `x` because it is borrowed + --> $DIR/binop-move-semantics.rs:31:5 + | +LL | let m = &x; + | -- borrow of `x` occurs here +... +LL | x //~ ERROR: cannot move out of `x` because it is borrowed + | ^ move out of `x` occurs here +... +LL | use_mut(n); use_imm(m); + | - borrow later used here + +error[E0505]: cannot move out of `y` because it is borrowed + --> $DIR/binop-move-semantics.rs:33:5 + | +LL | let n = &mut y; + | ------ borrow of `y` occurs here +... +LL | y; //~ ERROR: cannot move out of `y` because it is borrowed + | ^ move out of `y` occurs here +LL | use_mut(n); use_imm(m); + | - borrow later used here + error[E0507]: cannot move out of borrowed content --> $DIR/binop-move-semantics.rs:40:5 | @@ -62,7 +85,7 @@ LL | | &mut f; //~ ERROR: cannot borrow `f` as mutable because it is also b | | immutable borrow later used here | mutable borrow occurs here -error: aborting due to 6 previous errors +error: aborting due to 8 previous errors -Some errors occurred: E0382, E0502, E0507. +Some errors occurred: E0382, E0502, E0505, E0507. For more information about an error, try `rustc --explain E0382`. diff --git a/src/test/ui/binop/binop-move-semantics.rs b/src/test/ui/binop/binop-move-semantics.rs index cff0064497a..f6fad8b46dd 100644 --- a/src/test/ui/binop/binop-move-semantics.rs +++ b/src/test/ui/binop/binop-move-semantics.rs @@ -31,8 +31,8 @@ fn move_borrowed<T: Add<Output=()>>(x: T, mut y: T) { x //~ ERROR: cannot move out of `x` because it is borrowed + y; //~ ERROR: cannot move out of `y` because it is borrowed + use_mut(n); use_imm(m); } - fn illegal_dereference<T: Add<Output=()>>(mut x: T, y: T) { let m = &mut x; let n = &y; @@ -40,8 +40,8 @@ fn illegal_dereference<T: Add<Output=()>>(mut x: T, y: T) { *m //~ ERROR: cannot move out of borrowed content + *n; //~ ERROR: cannot move out of borrowed content + use_imm(n); use_mut(m); } - struct Foo; impl<'a, 'b> Add<&'b Foo> for &'a mut Foo { @@ -73,3 +73,6 @@ fn immut_plus_mut() { } fn main() {} + +fn use_mut<T>(_: &mut T) { } +fn use_imm<T>(_: &T) { } |
