diff options
| author | Fabian Wolff <fabian.wolff@alumni.ethz.ch> | 2022-01-15 21:33:11 +0100 |
|---|---|---|
| committer | Fabian Wolff <fabian.wolff@alumni.ethz.ch> | 2022-01-31 19:04:22 +0100 |
| commit | 0363f11ff03269d84eedb50d2130000fdfeceeb0 (patch) | |
| tree | baa4b2567a1594e9dd7e334e1d46d89bcfd54127 /src/test | |
| parent | c15ef58f4f67ee9ae02773642145650495f9f413 (diff) | |
Add match on `Vec<_>` to `ui/typeck/issue-91328.rs` test
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/ui/typeck/issue-91328.fixed | 10 | ||||
| -rw-r--r-- | src/test/ui/typeck/issue-91328.rs | 10 | ||||
| -rw-r--r-- | src/test/ui/typeck/issue-91328.stderr | 11 |
3 files changed, 30 insertions, 1 deletions
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<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() {} 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<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() {} 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<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`. |
