Skip to content

Commit 7b26f76

Browse files
committed
Run rustfix in pattern-slice-vec.rs UI test
1 parent c29aadd commit 7b26f76

File tree

3 files changed

+46
-4
lines changed

3 files changed

+46
-4
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Regression test for #87017.
2+
3+
// run-rustfix
4+
5+
fn main() {
6+
fn foo() -> Vec<i32> { vec![1, 2, 3] }
7+
8+
if let [_, _, _] = foo()[..] {}
9+
//~^ ERROR: expected an array or slice
10+
//~| HELP: consider slicing here
11+
12+
if let [] = &foo()[..] {}
13+
//~^ ERROR: expected an array or slice
14+
//~| HELP: consider slicing here
15+
16+
if let [] = foo()[..] {}
17+
//~^ ERROR: expected an array or slice
18+
//~| HELP: consider slicing here
19+
20+
let v = vec![];
21+
match &v[..] {
22+
//~^ HELP: consider slicing here
23+
[5] => {}
24+
//~^ ERROR: expected an array or slice
25+
_ => {}
26+
}
27+
}

src/test/ui/suggestions/pattern-slice-vec.rs

+7
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,22 @@
11
// Regression test for #87017.
22

3+
// run-rustfix
4+
35
fn main() {
46
fn foo() -> Vec<i32> { vec![1, 2, 3] }
57

68
if let [_, _, _] = foo() {}
79
//~^ ERROR: expected an array or slice
810
//~| HELP: consider slicing here
11+
912
if let [] = &foo() {}
1013
//~^ ERROR: expected an array or slice
1114
//~| HELP: consider slicing here
1215

16+
if let [] = foo() {}
17+
//~^ ERROR: expected an array or slice
18+
//~| HELP: consider slicing here
19+
1320
let v = vec![];
1421
match &v {
1522
//~^ HELP: consider slicing here
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,36 @@
11
error[E0529]: expected an array or slice, found `Vec<i32>`
2-
--> $DIR/pattern-slice-vec.rs:6:12
2+
--> $DIR/pattern-slice-vec.rs:8:12
33
|
44
LL | if let [_, _, _] = foo() {}
55
| ^^^^^^^^^ ----- help: consider slicing here: `foo()[..]`
66
| |
77
| pattern cannot match with input type `Vec<i32>`
88

99
error[E0529]: expected an array or slice, found `Vec<i32>`
10-
--> $DIR/pattern-slice-vec.rs:9:12
10+
--> $DIR/pattern-slice-vec.rs:12:12
1111
|
1212
LL | if let [] = &foo() {}
1313
| ^^ ------ help: consider slicing here: `&foo()[..]`
1414
| |
1515
| pattern cannot match with input type `Vec<i32>`
1616

17+
error[E0529]: expected an array or slice, found `Vec<i32>`
18+
--> $DIR/pattern-slice-vec.rs:16:12
19+
|
20+
LL | if let [] = foo() {}
21+
| ^^ ----- help: consider slicing here: `foo()[..]`
22+
| |
23+
| pattern cannot match with input type `Vec<i32>`
24+
1725
error[E0529]: expected an array or slice, found `Vec<_>`
18-
--> $DIR/pattern-slice-vec.rs:16:9
26+
--> $DIR/pattern-slice-vec.rs:23:9
1927
|
2028
LL | match &v {
2129
| -- help: consider slicing here: `&v[..]`
2230
LL |
2331
LL | [5] => {}
2432
| ^^^ pattern cannot match with input type `Vec<_>`
2533

26-
error: aborting due to 3 previous errors
34+
error: aborting due to 4 previous errors
2735

2836
For more information about this error, try `rustc --explain E0529`.

0 commit comments

Comments
 (0)