about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/ui/suggestions/suppress-consider-slicing-issue-120605.rs20
-rw-r--r--tests/ui/suggestions/suppress-consider-slicing-issue-120605.stderr23
2 files changed, 43 insertions, 0 deletions
diff --git a/tests/ui/suggestions/suppress-consider-slicing-issue-120605.rs b/tests/ui/suggestions/suppress-consider-slicing-issue-120605.rs
new file mode 100644
index 00000000000..135535cd00a
--- /dev/null
+++ b/tests/ui/suggestions/suppress-consider-slicing-issue-120605.rs
@@ -0,0 +1,20 @@
+pub struct Struct {
+    a: Vec<Struct>,
+}
+
+impl Struct {
+    pub fn test(&self) {
+        if let [Struct { a: [] }] = &self.a {
+            //~^ ERROR expected an array or slice
+            //~| ERROR expected an array or slice
+            println!("matches!")
+        }
+
+        if let [Struct { a: [] }] = &self.a[..] {
+            //~^ ERROR expected an array or slice
+            println!("matches!")
+        }
+    }
+}
+
+fn main() {}
diff --git a/tests/ui/suggestions/suppress-consider-slicing-issue-120605.stderr b/tests/ui/suggestions/suppress-consider-slicing-issue-120605.stderr
new file mode 100644
index 00000000000..c28d67604da
--- /dev/null
+++ b/tests/ui/suggestions/suppress-consider-slicing-issue-120605.stderr
@@ -0,0 +1,23 @@
+error[E0529]: expected an array or slice, found `Vec<Struct>`
+  --> $DIR/suppress-consider-slicing-issue-120605.rs:7:16
+   |
+LL |         if let [Struct { a: [] }] = &self.a {
+   |                ^^^^^^^^^^^^^^^^^^   ------- help: consider slicing here: `&self.a[..]`
+   |                |
+   |                pattern cannot match with input type `Vec<Struct>`
+
+error[E0529]: expected an array or slice, found `Vec<Struct>`
+  --> $DIR/suppress-consider-slicing-issue-120605.rs:7:29
+   |
+LL |         if let [Struct { a: [] }] = &self.a {
+   |                             ^^ pattern cannot match with input type `Vec<Struct>`
+
+error[E0529]: expected an array or slice, found `Vec<Struct>`
+  --> $DIR/suppress-consider-slicing-issue-120605.rs:13:29
+   |
+LL |         if let [Struct { a: [] }] = &self.a[..] {
+   |                             ^^ pattern cannot match with input type `Vec<Struct>`
+
+error: aborting due to 3 previous errors
+
+For more information about this error, try `rustc --explain E0529`.