-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #51201 - estebank:dotdot, r=petrochenkov
Accept `..` in incorrect position to avoid further errors We currently give a specific message when encountering a `..` anywhere other than the end of a pattern. Modify the parser to accept it (while still emitting the error) so that we don't also trigger "missing fields in pattern" errors afterwards. Add suggestions to either remove trailing `,` or moving the `..` to the end. Follow up to #49268.
- Loading branch information
Showing
4 changed files
with
169 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,38 @@ | ||
error: expected `}`, found `,` | ||
--> $DIR/issue-49257.rs:20:19 | ||
| | ||
LL | let Point { .., y } = p; //~ ERROR expected `}`, found `,` | ||
| ^ `..` must be in the last position, and cannot have a trailing comma | ||
LL | let Point { .., y, } = p; //~ ERROR expected `}`, found `,` | ||
| --^ | ||
| | | | ||
| | expected `}` | ||
| `..` must be at the end and cannot have a trailing comma | ||
help: move the `..` to the end of the field list | ||
| | ||
LL | let Point { y, .. } = p; //~ ERROR expected `}`, found `,` | ||
| -- ^^^^ | ||
|
||
error[E0027]: pattern does not mention fields `x`, `y` | ||
--> $DIR/issue-49257.rs:20:9 | ||
error: expected `}`, found `,` | ||
--> $DIR/issue-49257.rs:21:19 | ||
| | ||
LL | let Point { .., y } = p; //~ ERROR expected `}`, found `,` | ||
| ^^^^^^^^^^^^^^^ missing fields `x`, `y` | ||
| --^ | ||
| | | | ||
| | expected `}` | ||
| `..` must be at the end and cannot have a trailing comma | ||
help: move the `..` to the end of the field list | ||
| | ||
LL | let Point { y , .. } = p; //~ ERROR expected `}`, found `,` | ||
| -- ^^^^^^ | ||
|
||
error: expected `}`, found `,` | ||
--> $DIR/issue-49257.rs:22:19 | ||
| | ||
LL | let Point { .., } = p; //~ ERROR expected `}`, found `,` | ||
| --^ | ||
| | | | ||
| | expected `}` | ||
| | help: remove this comma | ||
| `..` must be at the end and cannot have a trailing comma | ||
|
||
error: aborting due to 2 previous errors | ||
error: aborting due to 3 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0027`. |