about summary refs log tree commit diff
path: root/tests/ui/match
diff options
context:
space:
mode:
authorEsteban Küber <esteban@kuber.com.ar>2023-11-17 00:55:55 +0000
committerEsteban Küber <esteban@kuber.com.ar>2023-11-17 00:55:55 +0000
commit5c3e01a340699069e1e8d9303fff0563fdbd09e2 (patch)
treeae3cb3518643d4947e89d6e18604dc2bae1eccfb /tests/ui/match
parent1be1e84872185c427de42f4d9e757d3e3e28d90e (diff)
downloadrust-5c3e01a340699069e1e8d9303fff0563fdbd09e2.tar.gz
rust-5c3e01a340699069e1e8d9303fff0563fdbd09e2.zip
On resolve error of `[rest..]`, suggest `[rest @ ..]`
When writing a pattern to collect multiple entries of a slice in a
single binding, it is easy to misremember or typo the appropriate syntax
to do so, instead writing the experimental `X..` pattern syntax. When we
encounter a resolve error because `X` isn't available, we suggest
`X @ ..` as an alternative.

```
error[E0425]: cannot find value `rest` in this scope
  --> $DIR/range-pattern-meant-to-be-slice-rest-pattern.rs:3:13
   |
LL |         [1, rest..] => println!("{rest:?}"),
   |             ^^^^ not found in this scope
   |
help: if you meant to collect the rest of the slice in `rest`, use the at operator
   |
LL |         [1, rest @ ..] => println!("{rest:?}"),
   |                  +
```

Fix #88404.
Diffstat (limited to 'tests/ui/match')
-rw-r--r--tests/ui/match/issue-92100.stderr5
1 files changed, 5 insertions, 0 deletions
diff --git a/tests/ui/match/issue-92100.stderr b/tests/ui/match/issue-92100.stderr
index 0f694c587fc..d0e50f3ae16 100644
--- a/tests/ui/match/issue-92100.stderr
+++ b/tests/ui/match/issue-92100.stderr
@@ -3,6 +3,11 @@ error[E0425]: cannot find value `a` in this scope
    |
 LL |         [a.., a] => {}
    |          ^ not found in this scope
+   |
+help: if you meant to collect the rest of the slice in `a`, use the at operator
+   |
+LL |         [a @ .., a] => {}
+   |            +
 
 error: aborting due to previous error