Add match on Vec<_> to ui/typeck/issue-91328.rs test

This commit is contained in:
Fabian Wolff 2022-01-15 21:33:11 +01:00
parent c15ef58f4f
commit 0363f11ff0
3 changed files with 30 additions and 1 deletions

View File

@ -24,4 +24,14 @@ fn bar(o: Option<Vec<i32>>) -> i32 {
}
}
fn baz(v: Vec<i32>) -> i32 {
match v[..] {
//~^ HELP: consider slicing here
[a, b] => a + b,
//~^ ERROR: expected an array or slice
//~| NOTE: pattern cannot match with input type
_ => 42,
}
}
fn main() {}

View File

@ -24,4 +24,14 @@ fn bar(o: Option<Vec<i32>>) -> i32 {
}
}
fn baz(v: Vec<i32>) -> i32 {
match v {
//~^ HELP: consider slicing here
[a, b] => a + b,
//~^ ERROR: expected an array or slice
//~| NOTE: pattern cannot match with input type
_ => 42,
}
}
fn main() {}

View File

@ -16,6 +16,15 @@ LL |
LL | Some([a, b]) => a + b,
| ^^^^^^ pattern cannot match with input type `Vec<i32>`
error: aborting due to 2 previous errors
error[E0529]: expected an array or slice, found `Vec<i32>`
--> $DIR/issue-91328.rs:30:9
|
LL | match v {
| - help: consider slicing here: `v[..]`
LL |
LL | [a, b] => a + b,
| ^^^^^^ pattern cannot match with input type `Vec<i32>`
error: aborting due to 3 previous errors
For more information about this error, try `rustc --explain E0529`.