diff options
| author | Esteban Küber <esteban@kuber.com.ar> | 2023-11-17 00:55:55 +0000 |
|---|---|---|
| committer | Esteban Küber <esteban@kuber.com.ar> | 2023-11-17 00:55:55 +0000 |
| commit | 5c3e01a340699069e1e8d9303fff0563fdbd09e2 (patch) | |
| tree | ae3cb3518643d4947e89d6e18604dc2bae1eccfb /tests/ui/match | |
| parent | 1be1e84872185c427de42f4d9e757d3e3e28d90e (diff) | |
| download | rust-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.stderr | 5 |
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 |
