mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-23 07:14:28 +00:00
Make ui/binop-move-semantics.rs
robust w.r.t. NLL.
This commit is contained in:
parent
62a2bb1294
commit
e940801592
@ -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`.
|
||||
|
@ -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) { }
|
||||
|
Loading…
Reference in New Issue
Block a user