about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorTakayuki Maeda <takoyaki0316@gmail.com>2022-04-17 01:20:11 +0900
committerTakayuki Maeda <takoyaki0316@gmail.com>2022-04-17 01:20:11 +0900
commita59cc5774b2b599e697db5175c331f5f98e42001 (patch)
tree96a45562654631f414361a40688012757c4a9208 /src/test
parente7575f9670f3c837def3d186ae09366c75c7632e (diff)
downloadrust-a59cc5774b2b599e697db5175c331f5f98e42001.tar.gz
rust-a59cc5774b2b599e697db5175c331f5f98e42001.zip
fix an invalid error for a suggestion to add a slice in pattern-matching
Diffstat (limited to 'src/test')
-rw-r--r--src/test/ui/suggestions/pattern-struct-with-slice-vec-field.rs13
-rw-r--r--src/test/ui/suggestions/pattern-struct-with-slice-vec-field.stderr9
2 files changed, 22 insertions, 0 deletions
diff --git a/src/test/ui/suggestions/pattern-struct-with-slice-vec-field.rs b/src/test/ui/suggestions/pattern-struct-with-slice-vec-field.rs
new file mode 100644
index 00000000000..1a9fc2f0050
--- /dev/null
+++ b/src/test/ui/suggestions/pattern-struct-with-slice-vec-field.rs
@@ -0,0 +1,13 @@
+struct Foo {
+    v: Vec<u32>,
+}
+
+fn f(foo: &Foo) {
+    match foo {
+        Foo { v: [1, 2] } => {}
+        //~^ ERROR expected an array or slice, found `Vec<u32>
+        _ => {}
+    }
+}
+
+fn main() {}
diff --git a/src/test/ui/suggestions/pattern-struct-with-slice-vec-field.stderr b/src/test/ui/suggestions/pattern-struct-with-slice-vec-field.stderr
new file mode 100644
index 00000000000..cb408d38fd2
--- /dev/null
+++ b/src/test/ui/suggestions/pattern-struct-with-slice-vec-field.stderr
@@ -0,0 +1,9 @@
+error[E0529]: expected an array or slice, found `Vec<u32>`
+  --> $DIR/pattern-struct-with-slice-vec-field.rs:7:18
+   |
+LL |         Foo { v: [1, 2] } => {}
+   |                  ^^^^^^ pattern cannot match with input type `Vec<u32>`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0529`.