Skip to content

Commit 41a1ee9

Browse files
committed
Make ui/unop-move-semantics.rs robust w.r.t. NLL.
1 parent 9843a38 commit 41a1ee9

File tree

2 files changed

+30
-4
lines changed

2 files changed

+30
-4
lines changed

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

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,29 @@ LL | x.clone(); //~ ERROR: use of moved value
99
|
1010
= note: move occurs because `x` has type `T`, which does not implement the `Copy` trait
1111

12+
error[E0505]: cannot move out of `x` because it is borrowed
13+
--> $DIR/unop-move-semantics.rs:25:6
14+
|
15+
LL | let m = &x;
16+
| -- borrow of `x` occurs here
17+
...
18+
LL | !x; //~ ERROR: cannot move out of `x` because it is borrowed
19+
| ^ move out of `x` occurs here
20+
...
21+
LL | use_mut(n); use_imm(m);
22+
| - borrow later used here
23+
24+
error[E0505]: cannot move out of `y` because it is borrowed
25+
--> $DIR/unop-move-semantics.rs:27:6
26+
|
27+
LL | let n = &mut y;
28+
| ------ borrow of `y` occurs here
29+
...
30+
LL | !y; //~ ERROR: cannot move out of `y` because it is borrowed
31+
| ^ move out of `y` occurs here
32+
LL | use_mut(n); use_imm(m);
33+
| - borrow later used here
34+
1235
error[E0507]: cannot move out of borrowed content
1336
--> $DIR/unop-move-semantics.rs:34:6
1437
|
@@ -21,7 +44,7 @@ error[E0507]: cannot move out of borrowed content
2144
LL | !*n; //~ ERROR: cannot move out of borrowed content
2245
| ^^ cannot move out of borrowed content
2346

24-
error: aborting due to 3 previous errors
47+
error: aborting due to 5 previous errors
2548

26-
Some errors occurred: E0382, E0507.
49+
Some errors occurred: E0382, E0505, E0507.
2750
For more information about an error, try `rustc --explain E0382`.

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,18 @@ fn move_borrowed<T: Not<Output=T>>(x: T, mut y: T) {
2525
!x; //~ ERROR: cannot move out of `x` because it is borrowed
2626

2727
!y; //~ ERROR: cannot move out of `y` because it is borrowed
28+
use_mut(n); use_imm(m);
2829
}
29-
3030
fn illegal_dereference<T: Not<Output=T>>(mut x: T, y: T) {
3131
let m = &mut x;
3232
let n = &y;
3333

3434
!*m; //~ ERROR: cannot move out of borrowed content
3535

3636
!*n; //~ ERROR: cannot move out of borrowed content
37+
use_imm(n); use_mut(m);
3738
}
38-
3939
fn main() {}
40+
41+
fn use_mut<T>(_: &mut T) { }
42+
fn use_imm<T>(_: &T) { }

0 commit comments

Comments
 (0)