2021-07-10 12:54:48 -05:00
|
|
|
// Regression test for #87017.
|
|
|
|
|
2024-02-16 14:02:50 -06:00
|
|
|
//@ run-rustfix
|
2021-08-02 11:35:49 -05:00
|
|
|
|
2021-07-10 12:54:48 -05:00
|
|
|
fn main() {
|
|
|
|
fn foo() -> Vec<i32> { vec![1, 2, 3] }
|
|
|
|
|
|
|
|
if let [_, _, _] = foo() {}
|
|
|
|
//~^ ERROR: expected an array or slice
|
|
|
|
//~| HELP: consider slicing here
|
2021-08-02 11:35:49 -05:00
|
|
|
|
2021-07-10 12:54:48 -05:00
|
|
|
if let [] = &foo() {}
|
|
|
|
//~^ ERROR: expected an array or slice
|
|
|
|
//~| HELP: consider slicing here
|
|
|
|
|
2021-08-02 11:35:49 -05:00
|
|
|
if let [] = foo() {}
|
|
|
|
//~^ ERROR: expected an array or slice
|
|
|
|
//~| HELP: consider slicing here
|
|
|
|
|
2021-07-10 12:54:48 -05:00
|
|
|
let v = vec![];
|
|
|
|
match &v {
|
|
|
|
//~^ HELP: consider slicing here
|
|
|
|
[5] => {}
|
|
|
|
//~^ ERROR: expected an array or slice
|
|
|
|
_ => {}
|
|
|
|
}
|
2022-07-29 01:02:11 -05:00
|
|
|
|
|
|
|
let [..] = vec![1, 2, 3];
|
|
|
|
//~^ ERROR: expected an array or slice
|
|
|
|
//~| HELP: consider slicing here
|
2021-07-10 12:54:48 -05:00
|
|
|
}
|