Skip to content

Commit

Permalink
Add match on Vec<_> to ui/typeck/issue-91328.rs test
Browse files Browse the repository at this point in the history
  • Loading branch information
FabianWolff committed Jan 31, 2022
1 parent c15ef58 commit 0363f11
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/test/ui/typeck/issue-91328.fixed
Expand Up @@ -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() {}
10 changes: 10 additions & 0 deletions src/test/ui/typeck/issue-91328.rs
Expand Up @@ -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() {}
11 changes: 10 additions & 1 deletion src/test/ui/typeck/issue-91328.stderr
Expand Up @@ -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`.

0 comments on commit 0363f11

Please sign in to comment.