Closed
Description
Given the following code: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=44c555e3d1e880be0fcff214d82cfe75
struct Foo {
v: Vec<u32>,
}
fn f(foo: &Foo) {
match foo {
Foo { v: [1, 2] } => { }
_ => { }
}
}
fn main() {
}
The current output is:
E0529: expected an array or slice, found `Vec<u32>`
--> src/main.rs:7:18
|
6 | match foo {
| --- help: consider slicing here: `foo[..]`
7 | Foo { v: [1, 2] } => { }
| ^^^^^^ pattern cannot match with input type `Vec<u32>`
For more information about this error, try `rustc --explain E0529`.
The suggestion to try writing foo[..]
is erroneous and would cause a different type error ("cannot index into a value of type &Foo
"). I believe the suggestion should be removed here.