From 0363f11ff03269d84eedb50d2130000fdfeceeb0 Mon Sep 17 00:00:00 2001 From: Fabian Wolff Date: Sat, 15 Jan 2022 21:33:11 +0100 Subject: [PATCH] Add match on `Vec<_>` to `ui/typeck/issue-91328.rs` test --- src/test/ui/typeck/issue-91328.fixed | 10 ++++++++++ src/test/ui/typeck/issue-91328.rs | 10 ++++++++++ src/test/ui/typeck/issue-91328.stderr | 11 ++++++++++- 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/src/test/ui/typeck/issue-91328.fixed b/src/test/ui/typeck/issue-91328.fixed index 48dc26718da..81b6a996072 100644 --- a/src/test/ui/typeck/issue-91328.fixed +++ b/src/test/ui/typeck/issue-91328.fixed @@ -24,4 +24,14 @@ fn bar(o: Option>) -> i32 { } } +fn baz(v: Vec) -> 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() {} diff --git a/src/test/ui/typeck/issue-91328.rs b/src/test/ui/typeck/issue-91328.rs index de5deb95349..e938d8f5c9f 100644 --- a/src/test/ui/typeck/issue-91328.rs +++ b/src/test/ui/typeck/issue-91328.rs @@ -24,4 +24,14 @@ fn bar(o: Option>) -> i32 { } } +fn baz(v: Vec) -> 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() {} diff --git a/src/test/ui/typeck/issue-91328.stderr b/src/test/ui/typeck/issue-91328.stderr index 4a9ddb2b927..96ad00cde4f 100644 --- a/src/test/ui/typeck/issue-91328.stderr +++ b/src/test/ui/typeck/issue-91328.stderr @@ -16,6 +16,15 @@ LL | LL | Some([a, b]) => a + b, | ^^^^^^ pattern cannot match with input type `Vec` -error: aborting due to 2 previous errors +error[E0529]: expected an array or slice, found `Vec` + --> $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` + +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0529`.