about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/test/ui/suggestions/pattern-slice-vec.fixed27
-rw-r--r--src/test/ui/suggestions/pattern-slice-vec.rs7
-rw-r--r--src/test/ui/suggestions/pattern-slice-vec.stderr16
3 files changed, 46 insertions, 4 deletions
diff --git a/src/test/ui/suggestions/pattern-slice-vec.fixed b/src/test/ui/suggestions/pattern-slice-vec.fixed
new file mode 100644
index 00000000000..447337c39c4
--- /dev/null
+++ b/src/test/ui/suggestions/pattern-slice-vec.fixed
@@ -0,0 +1,27 @@
+// Regression test for #87017.
+
+// run-rustfix
+
+fn main() {
+    fn foo() -> Vec<i32> { vec![1, 2, 3] }
+
+    if let [_, _, _] = foo()[..] {}
+    //~^ ERROR: expected an array or slice
+    //~| HELP: consider slicing here
+
+    if let [] = &foo()[..] {}
+    //~^ ERROR: expected an array or slice
+    //~| HELP: consider slicing here
+
+    if let [] = foo()[..] {}
+    //~^ ERROR: expected an array or slice
+    //~| HELP: consider slicing here
+
+    let v = vec![];
+    match &v[..] {
+    //~^ HELP: consider slicing here
+        [5] => {}
+        //~^ ERROR: expected an array or slice
+        _ => {}
+    }
+}
diff --git a/src/test/ui/suggestions/pattern-slice-vec.rs b/src/test/ui/suggestions/pattern-slice-vec.rs
index 1f010ae32a5..1153ca026bb 100644
--- a/src/test/ui/suggestions/pattern-slice-vec.rs
+++ b/src/test/ui/suggestions/pattern-slice-vec.rs
@@ -1,15 +1,22 @@
 // Regression test for #87017.
 
+// run-rustfix
+
 fn main() {
     fn foo() -> Vec<i32> { vec![1, 2, 3] }
 
     if let [_, _, _] = foo() {}
     //~^ ERROR: expected an array or slice
     //~| HELP: consider slicing here
+
     if let [] = &foo() {}
     //~^ ERROR: expected an array or slice
     //~| HELP: consider slicing here
 
+    if let [] = foo() {}
+    //~^ ERROR: expected an array or slice
+    //~| HELP: consider slicing here
+
     let v = vec![];
     match &v {
     //~^ HELP: consider slicing here
diff --git a/src/test/ui/suggestions/pattern-slice-vec.stderr b/src/test/ui/suggestions/pattern-slice-vec.stderr
index a6337cc66bf..403a816ba11 100644
--- a/src/test/ui/suggestions/pattern-slice-vec.stderr
+++ b/src/test/ui/suggestions/pattern-slice-vec.stderr
@@ -1,5 +1,5 @@
 error[E0529]: expected an array or slice, found `Vec<i32>`
-  --> $DIR/pattern-slice-vec.rs:6:12
+  --> $DIR/pattern-slice-vec.rs:8:12
    |
 LL |     if let [_, _, _] = foo() {}
    |            ^^^^^^^^^   ----- help: consider slicing here: `foo()[..]`
@@ -7,15 +7,23 @@ LL |     if let [_, _, _] = foo() {}
    |            pattern cannot match with input type `Vec<i32>`
 
 error[E0529]: expected an array or slice, found `Vec<i32>`
-  --> $DIR/pattern-slice-vec.rs:9:12
+  --> $DIR/pattern-slice-vec.rs:12:12
    |
 LL |     if let [] = &foo() {}
    |            ^^   ------ help: consider slicing here: `&foo()[..]`
    |            |
    |            pattern cannot match with input type `Vec<i32>`
 
+error[E0529]: expected an array or slice, found `Vec<i32>`
+  --> $DIR/pattern-slice-vec.rs:16:12
+   |
+LL |     if let [] = foo() {}
+   |            ^^   ----- help: consider slicing here: `foo()[..]`
+   |            |
+   |            pattern cannot match with input type `Vec<i32>`
+
 error[E0529]: expected an array or slice, found `Vec<_>`
-  --> $DIR/pattern-slice-vec.rs:16:9
+  --> $DIR/pattern-slice-vec.rs:23:9
    |
 LL |     match &v {
    |           -- help: consider slicing here: `&v[..]`
@@ -23,6 +31,6 @@ LL |
 LL |         [5] => {}
    |         ^^^ pattern cannot match with input type `Vec<_>`
 
-error: aborting due to 3 previous errors
+error: aborting due to 4 previous errors
 
 For more information about this error, try `rustc --explain E0529`.