Commit d19b51e
authored
Rollup merge of rust-lang#72534 - chrissimpkins:fix-72373, r=estebank
Improve missing `@` in slice binding pattern diagnostics
Closes rust-lang#72373
Includes a new suggestion with `Applicability::MaybeIncorrect` confidence level.
Before:
```
--> src/main.rs:5:19
|
5 | [h, ref ts..] => foo(c, n - h) + foo(ts, n),
| -^
| |
| expected one of `,`, `@`, `]`, or `|`
| help: missing `,`
error[E0308]: mismatched types
--> src/main.rs:5:46
|
5 | [h, ref ts..] => foo(c, n - h) + foo(ts, n),
| ^^ expected slice `[u32]`, found `u32`
|
= note: expected reference `&[u32]`
found reference `&u32`
error: aborting due to 2 previous errors
```
After:
```
error: expected one of `,`, `@`, `]`, or `|`, found `..`
--> src/main.rs:5:20
|
5 | [h, ref ts..] => foo(c, n - h) + foo(ts, n),
| ^^ expected one of `,`, `@`, `]`, or `|`
|
help: if you meant to bind the contents of the rest of the array pattern into `ts`, use `@`
|
5 | [h, ref ts @ ..] => foo(c, n - h) + foo(ts, n),
| ^
error: aborting due to previous error
```
r? @estebankFile tree
3 files changed
+42
-0
lines changed- src
- librustc_parse/parser
- test/ui/issues
3 files changed
+42
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
672 | 672 | | |
673 | 673 | | |
674 | 674 | | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
675 | 695 | | |
676 | 696 | | |
677 | 697 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
0 commit comments