about summary refs log tree commit diff
path: root/tests/ui/pattern/range-pattern-meant-to-be-slice-rest-pattern.rs
diff options
context:
space:
mode:
authorLeón Orell Valerian Liehr <me@fmease.dev>2024-02-03 01:32:01 +0100
committerLeón Orell Valerian Liehr <me@fmease.dev>2024-02-04 22:16:21 +0100
commit285d8c225d05966040f6a69bfdea83165b54483f (patch)
tree18dc88664286add9ebb16ac5f3108c7c7748b079 /tests/ui/pattern/range-pattern-meant-to-be-slice-rest-pattern.rs
parent4e3eed48926b8b70eee8beb082e37ffa4985c0ed (diff)
downloadrust-285d8c225d05966040f6a69bfdea83165b54483f.tar.gz
rust-285d8c225d05966040f6a69bfdea83165b54483f.zip
Suggest `[tail @ ..]` on `[..tail]` and `[...tail]` where `tail` is unresolved
Diffstat (limited to 'tests/ui/pattern/range-pattern-meant-to-be-slice-rest-pattern.rs')
-rw-r--r--tests/ui/pattern/range-pattern-meant-to-be-slice-rest-pattern.rs16
1 files changed, 15 insertions, 1 deletions
diff --git a/tests/ui/pattern/range-pattern-meant-to-be-slice-rest-pattern.rs b/tests/ui/pattern/range-pattern-meant-to-be-slice-rest-pattern.rs
index a619fcafc86..1eba7aeb4d6 100644
--- a/tests/ui/pattern/range-pattern-meant-to-be-slice-rest-pattern.rs
+++ b/tests/ui/pattern/range-pattern-meant-to-be-slice-rest-pattern.rs
@@ -1,9 +1,23 @@
 fn main() {
     match &[1, 2, 3][..] {
-        [1, rest..] => println!("{rest:?}"),
+        [1, rest..] => println!("{rest}"),
         //~^ ERROR cannot find value `rest` in this scope
         //~| ERROR cannot find value `rest` in this scope
         //~| ERROR `X..` patterns in slices are experimental
         _ => {}
     }
+    match &[4, 5, 6][..] {
+        [] => {}
+        [_, ..tail] => println!("{tail}"),
+        //~^ ERROR cannot find value `tail` in this scope
+        //~| ERROR cannot find value `tail` in this scope
+        //~| ERROR exclusive range pattern syntax is experimental
+    }
+    match &[7, 8, 9][..] {
+        [] => {}
+        [_, ...tail] => println!("{tail}"),
+        //~^ ERROR cannot find value `tail` in this scope
+        //~| ERROR cannot find value `tail` in this scope
+        //~| ERROR range-to patterns with `...` are not allowed
+    }
 }