Skip to content

Commit 2cb0a06

Browse files
committed
Update tests for grouped nll move errors
1 parent 0193d1f commit 2cb0a06

16 files changed

+378
-104
lines changed

src/test/compile-fail/borrowck/borrowck-move-out-of-struct-with-dtor.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ impl Drop for S {
1818

1919
fn move_in_match() {
2020
match (S {f:"foo".to_string()}) {
21+
//[mir]~^ ERROR [E0509]
2122
S {f:_s} => {}
2223
//[ast]~^ ERROR cannot move out of type `S`, which implements the `Drop` trait [E0509]
23-
//[mir]~^^ ERROR [E0509]
2424
}
2525
}
2626

src/test/ui/E0508.ast.nll.stderr

-9
This file was deleted.

src/test/ui/E0508.mir.stderr

-9
This file was deleted.

src/test/ui/E0508.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,9 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
// revisions: ast mir
12-
//[mir]compile-flags: -Z borrowck=mir
13-
1411
struct NonCopy;
1512

1613
fn main() {
1714
let array = [NonCopy; 1];
18-
let _value = array[0]; //[ast]~ ERROR [E0508]
19-
//[mir]~^ ERROR [E0508]
15+
let _value = array[0]; //~ ERROR [E0508]
2016
}

src/test/ui/E0508.ast.stderr renamed to src/test/ui/E0508.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
error[E0508]: cannot move out of type `[NonCopy; 1]`, a non-copy array
2-
--> $DIR/E0508.rs:18:18
2+
--> $DIR/E0508.rs:15:18
33
|
4-
LL | let _value = array[0]; //[ast]~ ERROR [E0508]
4+
LL | let _value = array[0]; //~ ERROR [E0508]
55
| ^^^^^^^^
66
| |
77
| cannot move out of here
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,46 @@
11
error[E0507]: cannot move out of borrowed content
2-
--> $DIR/borrowck-move-error-with-note.rs:23:19
2+
--> $DIR/borrowck-move-error-with-note.rs:21:11
33
|
4+
LL | match *f { //~ ERROR cannot move out of
5+
| ^^
6+
| |
7+
| cannot move out of borrowed content
8+
| help: consider removing this dereference operator: `f`
9+
LL | //~| cannot move out
410
LL | Foo::Foo1(num1,
5-
| ^^^^ cannot move out of borrowed content
6-
7-
error[E0507]: cannot move out of borrowed content
8-
--> $DIR/borrowck-move-error-with-note.rs:24:19
9-
|
11+
| ---- move occurs because num1 has type `std::boxed::Box<u32>`, which does not implement the `Copy` trait
1012
LL | num2) => (),
11-
| ^^^^ cannot move out of borrowed content
12-
13-
error[E0507]: cannot move out of borrowed content
14-
--> $DIR/borrowck-move-error-with-note.rs:25:19
15-
|
13+
| ---- move occurs because num2 has type `std::boxed::Box<u32>`, which does not implement the `Copy` trait
1614
LL | Foo::Foo2(num) => (),
17-
| ^^^ cannot move out of borrowed content
15+
| --- move occurs because num has type `std::boxed::Box<u32>`, which does not implement the `Copy` trait
1816

1917
error[E0509]: cannot move out of type `S`, which implements the `Drop` trait
20-
--> $DIR/borrowck-move-error-with-note.rs:42:16
18+
--> $DIR/borrowck-move-error-with-note.rs:39:11
2119
|
22-
LL | f: _s,
23-
| ^^ cannot move out of here
24-
25-
error[E0509]: cannot move out of type `S`, which implements the `Drop` trait
26-
--> $DIR/borrowck-move-error-with-note.rs:43:16
20+
LL | match (S {f: "foo".to_string(), g: "bar".to_string()}) {
21+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot move out of here
22+
help: to prevent move, use ref or ref mut
23+
|
24+
LL | f: ref _s,
25+
| ^^^^^^
26+
help: to prevent move, use ref or ref mut
2727
|
28-
LL | g: _t
29-
| ^^ cannot move out of here
28+
LL | g: ref _t
29+
| ^^^^^^
3030

3131
error[E0507]: cannot move out of borrowed content
32-
--> $DIR/borrowck-move-error-with-note.rs:59:9
32+
--> $DIR/borrowck-move-error-with-note.rs:57:11
3333
|
34+
LL | match a.a { //~ ERROR cannot move out of
35+
| ^^^
36+
| |
37+
| cannot move out of borrowed content
38+
| help: consider using a reference instead: `&a.a`
39+
LL | //~| cannot move out
3440
LL | n => {
35-
| ^ cannot move out of borrowed content
41+
| - move occurs because n has type `std::boxed::Box<isize>`, which does not implement the `Copy` trait
3642

37-
error: aborting due to 6 previous errors
43+
error: aborting due to 3 previous errors
3844

3945
Some errors occurred: E0507, E0509.
4046
For more information about an error, try `rustc --explain E0507`.
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
error[E0508]: cannot move out of type `[Foo]`, a non-copy slice
2-
--> $DIR/borrowck-move-out-of-vec-tail.rs:30:33
2+
--> $DIR/borrowck-move-out-of-vec-tail.rs:29:19
33
|
4-
LL | &[Foo { string: a },
5-
| ^ cannot move out of here
6-
7-
error[E0508]: cannot move out of type `[Foo]`, a non-copy slice
8-
--> $DIR/borrowck-move-out-of-vec-tail.rs:34:33
4+
LL | match tail {
5+
| ^^^^ cannot move out of here
6+
help: to prevent move, use ref or ref mut
7+
|
8+
LL | &[Foo { string: ref a },
9+
| ^^^^^
10+
help: to prevent move, use ref or ref mut
911
|
10-
LL | Foo { string: b }] => {
11-
| ^ cannot move out of here
12+
LL | Foo { string: ref b }] => {
13+
| ^^^^^
1214

13-
error: aborting due to 2 previous errors
15+
error: aborting due to previous error
1416

1517
For more information about this error, try `rustc --explain E0508`.

src/test/ui/borrowck/borrowck-vec-pattern-nesting.nll.stderr

+35-21
Original file line numberDiff line numberDiff line change
@@ -23,54 +23,68 @@ LL | _b.use_ref();
2323
| -- borrow later used here
2424

2525
error[E0508]: cannot move out of type `[std::boxed::Box<isize>]`, a non-copy slice
26-
--> $DIR/borrowck-vec-pattern-nesting.rs:44:15
26+
--> $DIR/borrowck-vec-pattern-nesting.rs:43:11
2727
|
28+
LL | match vec {
29+
| ^^^ cannot move out of here
2830
LL | &mut [_a, //~ ERROR cannot move out
29-
| ^^ cannot move out of here
31+
| -- help: to prevent move, use ref or ref mut: `ref _a`
3032

3133
error[E0508]: cannot move out of type `[std::boxed::Box<isize>]`, a non-copy slice
3234
--> $DIR/borrowck-vec-pattern-nesting.rs:57:13
3335
|
3436
LL | let a = vec[0]; //~ ERROR cannot move out
35-
| ^^^^^^ cannot move out of here
37+
| ^^^^^^
38+
| |
39+
| cannot move out of here
40+
| help: consider using a reference instead: `&vec[0]`
3641

3742
error[E0508]: cannot move out of type `[std::boxed::Box<isize>]`, a non-copy slice
38-
--> $DIR/borrowck-vec-pattern-nesting.rs:67:10
43+
--> $DIR/borrowck-vec-pattern-nesting.rs:64:11
3944
|
45+
LL | match vec {
46+
| ^^^ cannot move out of here
47+
...
4048
LL | _b] => {}
41-
| ^^ cannot move out of here
49+
| -- help: to prevent move, use ref or ref mut: `ref _b`
4250

4351
error[E0508]: cannot move out of type `[std::boxed::Box<isize>]`, a non-copy slice
4452
--> $DIR/borrowck-vec-pattern-nesting.rs:70:13
4553
|
4654
LL | let a = vec[0]; //~ ERROR cannot move out
47-
| ^^^^^^ cannot move out of here
55+
| ^^^^^^
56+
| |
57+
| cannot move out of here
58+
| help: consider using a reference instead: `&vec[0]`
4859

4960
error[E0508]: cannot move out of type `[std::boxed::Box<isize>]`, a non-copy slice
50-
--> $DIR/borrowck-vec-pattern-nesting.rs:78:15
61+
--> $DIR/borrowck-vec-pattern-nesting.rs:77:11
5162
|
52-
LL | &mut [_a, _b, _c] => {} //~ ERROR cannot move out
53-
| ^^ cannot move out of here
54-
55-
error[E0508]: cannot move out of type `[std::boxed::Box<isize>]`, a non-copy slice
56-
--> $DIR/borrowck-vec-pattern-nesting.rs:78:19
63+
LL | match vec {
64+
| ^^^ cannot move out of here
65+
help: to prevent move, use ref or ref mut
5766
|
58-
LL | &mut [_a, _b, _c] => {} //~ ERROR cannot move out
59-
| ^^ cannot move out of here
60-
61-
error[E0508]: cannot move out of type `[std::boxed::Box<isize>]`, a non-copy slice
62-
--> $DIR/borrowck-vec-pattern-nesting.rs:78:23
67+
LL | &mut [ref _a, _b, _c] => {} //~ ERROR cannot move out
68+
| ^^^^^^
69+
help: to prevent move, use ref or ref mut
70+
|
71+
LL | &mut [_a, ref _b, _c] => {} //~ ERROR cannot move out
72+
| ^^^^^^
73+
help: to prevent move, use ref or ref mut
6374
|
64-
LL | &mut [_a, _b, _c] => {} //~ ERROR cannot move out
65-
| ^^ cannot move out of here
75+
LL | &mut [_a, _b, ref _c] => {} //~ ERROR cannot move out
76+
| ^^^^^^
6677

6778
error[E0508]: cannot move out of type `[std::boxed::Box<isize>]`, a non-copy slice
6879
--> $DIR/borrowck-vec-pattern-nesting.rs:82:13
6980
|
7081
LL | let a = vec[0]; //~ ERROR cannot move out
71-
| ^^^^^^ cannot move out of here
82+
| ^^^^^^
83+
| |
84+
| cannot move out of here
85+
| help: consider using a reference instead: `&vec[0]`
7286

73-
error: aborting due to 10 previous errors
87+
error: aborting due to 8 previous errors
7488

7589
Some errors occurred: E0506, E0508.
7690
For more information about an error, try `rustc --explain E0506`.

src/test/ui/borrowck/issue-51415.nll.stderr

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
error[E0507]: cannot move out of borrowed content
2-
--> $DIR/issue-51415.rs:16:47
2+
--> $DIR/issue-51415.rs:16:42
33
|
44
LL | let opt = a.iter().enumerate().find(|(_, &s)| {
5-
| ^ cannot move out of borrowed content
5+
| ^^^^^-^
6+
| | |
7+
| | help: to prevent move, use ref or ref mut: `ref s`
8+
| cannot move out of borrowed content
69

710
error: aborting due to previous error
811

src/test/ui/codemap_tests/overlapping_spans.nll.stderr

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
error[E0509]: cannot move out of type `S`, which implements the `Drop` trait
2-
--> $DIR/overlapping_spans.rs:21:14
2+
--> $DIR/overlapping_spans.rs:20:11
33
|
4+
LL | match (S {f:"foo".to_string()}) {
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^ cannot move out of here
46
LL | S {f:_s} => {} //~ ERROR cannot move out
5-
| ^^ cannot move out of here
7+
| -- help: to prevent move, use ref or ref mut: `ref _s`
68

79
error: aborting due to previous error
810

src/test/ui/error-codes/E0509.nll.stderr

-9
This file was deleted.

src/test/ui/issue-40402-ref-hints/issue-40402-1.nll.stderr

+4-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ error[E0507]: cannot move out of borrowed content
22
--> $DIR/issue-40402-1.rs:19:13
33
|
44
LL | let e = f.v[0]; //~ ERROR cannot move out of indexed content
5-
| ^^^^^^ cannot move out of borrowed content
5+
| ^^^^^^
6+
| |
7+
| cannot move out of borrowed content
8+
| help: consider using a reference instead: `&f.v[0]`
69

710
error: aborting due to previous error
811

Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
error[E0507]: cannot move out of borrowed content
2-
--> $DIR/issue-40402-2.rs:15:10
2+
--> $DIR/issue-40402-2.rs:15:18
33
|
44
LL | let (a, b) = x[0]; //~ ERROR cannot move out of indexed content
5-
| ^ cannot move out of borrowed content
5+
| - - ^^^^
6+
| | | |
7+
| | | cannot move out of borrowed content
8+
| | | help: consider using a reference instead: `&x[0]`
9+
| | move occurs because b has type `std::string::String`, which does not implement the `Copy` trait
10+
| move occurs because a has type `std::string::String`, which does not implement the `Copy` trait
611

7-
error[E0507]: cannot move out of borrowed content
8-
--> $DIR/issue-40402-2.rs:15:13
9-
|
10-
LL | let (a, b) = x[0]; //~ ERROR cannot move out of indexed content
11-
| ^ cannot move out of borrowed content
12-
13-
error: aborting due to 2 previous errors
12+
error: aborting due to previous error
1413

1514
For more information about this error, try `rustc --explain E0507`.

src/test/ui/moves-based-on-type-block-bad.nll.stderr

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
error[E0507]: cannot move out of borrowed content
2-
--> $DIR/moves-based-on-type-block-bad.rs:37:28
2+
--> $DIR/moves-based-on-type-block-bad.rs:34:19
33
|
4+
LL | match hellothere.x { //~ ERROR cannot move out
5+
| ^^^^^^^^^^^^
6+
| |
7+
| cannot move out of borrowed content
8+
| help: consider using a reference instead: `&hellothere.x`
9+
...
410
LL | box E::Bar(x) => println!("{}", x.to_string()),
5-
| ^ cannot move out of borrowed content
11+
| - move occurs because x has type `std::boxed::Box<isize>`, which does not implement the `Copy` trait
612

713
error: aborting due to previous error
814

0 commit comments

Comments
 (0)