Skip to content

Commit 0363f11

Browse files
committed
Add match on Vec<_> to ui/typeck/issue-91328.rs test
1 parent c15ef58 commit 0363f11

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed

src/test/ui/typeck/issue-91328.fixed

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,14 @@ fn bar(o: Option<Vec<i32>>) -> i32 {
2424
}
2525
}
2626

27+
fn baz(v: Vec<i32>) -> i32 {
28+
match v[..] {
29+
//~^ HELP: consider slicing here
30+
[a, b] => a + b,
31+
//~^ ERROR: expected an array or slice
32+
//~| NOTE: pattern cannot match with input type
33+
_ => 42,
34+
}
35+
}
36+
2737
fn main() {}

src/test/ui/typeck/issue-91328.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,14 @@ fn bar(o: Option<Vec<i32>>) -> i32 {
2424
}
2525
}
2626

27+
fn baz(v: Vec<i32>) -> i32 {
28+
match v {
29+
//~^ HELP: consider slicing here
30+
[a, b] => a + b,
31+
//~^ ERROR: expected an array or slice
32+
//~| NOTE: pattern cannot match with input type
33+
_ => 42,
34+
}
35+
}
36+
2737
fn main() {}

src/test/ui/typeck/issue-91328.stderr

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,15 @@ LL |
1616
LL | Some([a, b]) => a + b,
1717
| ^^^^^^ pattern cannot match with input type `Vec<i32>`
1818

19-
error: aborting due to 2 previous errors
19+
error[E0529]: expected an array or slice, found `Vec<i32>`
20+
--> $DIR/issue-91328.rs:30:9
21+
|
22+
LL | match v {
23+
| - help: consider slicing here: `v[..]`
24+
LL |
25+
LL | [a, b] => a + b,
26+
| ^^^^^^ pattern cannot match with input type `Vec<i32>`
27+
28+
error: aborting due to 3 previous errors
2029

2130
For more information about this error, try `rustc --explain E0529`.

0 commit comments

Comments
 (0)