Skip to content

Commit e940801

Browse files
committed
Make ui/binop-move-semantics.rs robust w.r.t. NLL.
1 parent 62a2bb1 commit e940801

File tree

2 files changed

+30
-4
lines changed

2 files changed

+30
-4
lines changed

src/test/ui/binop/binop-move-semantics.nll.stderr

+25-2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,29 @@ LL | x.clone(); //~ ERROR: use of moved value
2020
|
2121
= note: move occurs because `x` has type `T`, which does not implement the `Copy` trait
2222

23+
error[E0505]: cannot move out of `x` because it is borrowed
24+
--> $DIR/binop-move-semantics.rs:31:5
25+
|
26+
LL | let m = &x;
27+
| -- borrow of `x` occurs here
28+
...
29+
LL | x //~ ERROR: cannot move out of `x` because it is borrowed
30+
| ^ move out of `x` occurs here
31+
...
32+
LL | use_mut(n); use_imm(m);
33+
| - borrow later used here
34+
35+
error[E0505]: cannot move out of `y` because it is borrowed
36+
--> $DIR/binop-move-semantics.rs:33:5
37+
|
38+
LL | let n = &mut y;
39+
| ------ borrow of `y` occurs here
40+
...
41+
LL | y; //~ ERROR: cannot move out of `y` because it is borrowed
42+
| ^ move out of `y` occurs here
43+
LL | use_mut(n); use_imm(m);
44+
| - borrow later used here
45+
2346
error[E0507]: cannot move out of borrowed content
2447
--> $DIR/binop-move-semantics.rs:40:5
2548
|
@@ -62,7 +85,7 @@ LL | | &mut f; //~ ERROR: cannot borrow `f` as mutable because it is also b
6285
| | immutable borrow later used here
6386
| mutable borrow occurs here
6487

65-
error: aborting due to 6 previous errors
88+
error: aborting due to 8 previous errors
6689

67-
Some errors occurred: E0382, E0502, E0507.
90+
Some errors occurred: E0382, E0502, E0505, E0507.
6891
For more information about an error, try `rustc --explain E0382`.

src/test/ui/binop/binop-move-semantics.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,17 @@ fn move_borrowed<T: Add<Output=()>>(x: T, mut y: T) {
3131
x //~ ERROR: cannot move out of `x` because it is borrowed
3232
+
3333
y; //~ ERROR: cannot move out of `y` because it is borrowed
34+
use_mut(n); use_imm(m);
3435
}
35-
3636
fn illegal_dereference<T: Add<Output=()>>(mut x: T, y: T) {
3737
let m = &mut x;
3838
let n = &y;
3939

4040
*m //~ ERROR: cannot move out of borrowed content
4141
+
4242
*n; //~ ERROR: cannot move out of borrowed content
43+
use_imm(n); use_mut(m);
4344
}
44-
4545
struct Foo;
4646

4747
impl<'a, 'b> Add<&'b Foo> for &'a mut Foo {
@@ -73,3 +73,6 @@ fn immut_plus_mut() {
7373
}
7474

7575
fn main() {}
76+
77+
fn use_mut<T>(_: &mut T) { }
78+
fn use_imm<T>(_: &T) { }

0 commit comments

Comments
 (0)