mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-08 21:13:55 +00:00
Run rustfix in pattern-slice-vec.rs
UI test
This commit is contained in:
parent
c29aadd9cf
commit
7b26f76cb5
27
src/test/ui/suggestions/pattern-slice-vec.fixed
Normal file
27
src/test/ui/suggestions/pattern-slice-vec.fixed
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
// Regression test for #87017.
|
||||||
|
|
||||||
|
// run-rustfix
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
fn foo() -> Vec<i32> { vec![1, 2, 3] }
|
||||||
|
|
||||||
|
if let [_, _, _] = foo()[..] {}
|
||||||
|
//~^ ERROR: expected an array or slice
|
||||||
|
//~| HELP: consider slicing here
|
||||||
|
|
||||||
|
if let [] = &foo()[..] {}
|
||||||
|
//~^ ERROR: expected an array or slice
|
||||||
|
//~| HELP: consider slicing here
|
||||||
|
|
||||||
|
if let [] = foo()[..] {}
|
||||||
|
//~^ ERROR: expected an array or slice
|
||||||
|
//~| HELP: consider slicing here
|
||||||
|
|
||||||
|
let v = vec![];
|
||||||
|
match &v[..] {
|
||||||
|
//~^ HELP: consider slicing here
|
||||||
|
[5] => {}
|
||||||
|
//~^ ERROR: expected an array or slice
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
}
|
@ -1,15 +1,22 @@
|
|||||||
// Regression test for #87017.
|
// Regression test for #87017.
|
||||||
|
|
||||||
|
// run-rustfix
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
fn foo() -> Vec<i32> { vec![1, 2, 3] }
|
fn foo() -> Vec<i32> { vec![1, 2, 3] }
|
||||||
|
|
||||||
if let [_, _, _] = foo() {}
|
if let [_, _, _] = foo() {}
|
||||||
//~^ ERROR: expected an array or slice
|
//~^ ERROR: expected an array or slice
|
||||||
//~| HELP: consider slicing here
|
//~| HELP: consider slicing here
|
||||||
|
|
||||||
if let [] = &foo() {}
|
if let [] = &foo() {}
|
||||||
//~^ ERROR: expected an array or slice
|
//~^ ERROR: expected an array or slice
|
||||||
//~| HELP: consider slicing here
|
//~| HELP: consider slicing here
|
||||||
|
|
||||||
|
if let [] = foo() {}
|
||||||
|
//~^ ERROR: expected an array or slice
|
||||||
|
//~| HELP: consider slicing here
|
||||||
|
|
||||||
let v = vec![];
|
let v = vec![];
|
||||||
match &v {
|
match &v {
|
||||||
//~^ HELP: consider slicing here
|
//~^ HELP: consider slicing here
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
error[E0529]: expected an array or slice, found `Vec<i32>`
|
error[E0529]: expected an array or slice, found `Vec<i32>`
|
||||||
--> $DIR/pattern-slice-vec.rs:6:12
|
--> $DIR/pattern-slice-vec.rs:8:12
|
||||||
|
|
|
|
||||||
LL | if let [_, _, _] = foo() {}
|
LL | if let [_, _, _] = foo() {}
|
||||||
| ^^^^^^^^^ ----- help: consider slicing here: `foo()[..]`
|
| ^^^^^^^^^ ----- help: consider slicing here: `foo()[..]`
|
||||||
@ -7,15 +7,23 @@ LL | if let [_, _, _] = foo() {}
|
|||||||
| pattern cannot match with input type `Vec<i32>`
|
| pattern cannot match with input type `Vec<i32>`
|
||||||
|
|
||||||
error[E0529]: expected an array or slice, found `Vec<i32>`
|
error[E0529]: expected an array or slice, found `Vec<i32>`
|
||||||
--> $DIR/pattern-slice-vec.rs:9:12
|
--> $DIR/pattern-slice-vec.rs:12:12
|
||||||
|
|
|
|
||||||
LL | if let [] = &foo() {}
|
LL | if let [] = &foo() {}
|
||||||
| ^^ ------ help: consider slicing here: `&foo()[..]`
|
| ^^ ------ help: consider slicing here: `&foo()[..]`
|
||||||
| |
|
| |
|
||||||
| pattern cannot match with input type `Vec<i32>`
|
| pattern cannot match with input type `Vec<i32>`
|
||||||
|
|
||||||
|
error[E0529]: expected an array or slice, found `Vec<i32>`
|
||||||
|
--> $DIR/pattern-slice-vec.rs:16:12
|
||||||
|
|
|
||||||
|
LL | if let [] = foo() {}
|
||||||
|
| ^^ ----- help: consider slicing here: `foo()[..]`
|
||||||
|
| |
|
||||||
|
| pattern cannot match with input type `Vec<i32>`
|
||||||
|
|
||||||
error[E0529]: expected an array or slice, found `Vec<_>`
|
error[E0529]: expected an array or slice, found `Vec<_>`
|
||||||
--> $DIR/pattern-slice-vec.rs:16:9
|
--> $DIR/pattern-slice-vec.rs:23:9
|
||||||
|
|
|
|
||||||
LL | match &v {
|
LL | match &v {
|
||||||
| -- help: consider slicing here: `&v[..]`
|
| -- help: consider slicing here: `&v[..]`
|
||||||
@ -23,6 +31,6 @@ LL |
|
|||||||
LL | [5] => {}
|
LL | [5] => {}
|
||||||
| ^^^ pattern cannot match with input type `Vec<_>`
|
| ^^^ pattern cannot match with input type `Vec<_>`
|
||||||
|
|
||||||
error: aborting due to 3 previous errors
|
error: aborting due to 4 previous errors
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0529`.
|
For more information about this error, try `rustc --explain E0529`.
|
||||||
|
Loading…
Reference in New Issue
Block a user