-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Suggest comma when missing in macro call
When missing a comma in a macro call, suggest it, regardless of position. When a macro call doesn't match any of the patterns, check if the call's token stream could be missing a comma between two idents, and if so, create a new token stream containing the comma and try to match against the macro patterns. If successful, emit the suggestion.
- Loading branch information
Showing
4 changed files
with
73 additions
and
19 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,16 +1,38 @@ | ||
error: expected token: `,` | ||
--> $DIR/missing-comma.rs:16:19 | ||
--> $DIR/missing-comma.rs:20:19 | ||
| | ||
LL | println!("{}" a); | ||
| ^ | ||
|
||
error: no rules expected the token `b` | ||
--> $DIR/missing-comma.rs:18:12 | ||
--> $DIR/missing-comma.rs:22:12 | ||
| | ||
LL | foo!(a b); | ||
| -^ | ||
| | | ||
| help: missing comma here | ||
|
||
error: aborting due to 2 previous errors | ||
error: no rules expected the token `e` | ||
--> $DIR/missing-comma.rs:24:21 | ||
| | ||
LL | foo!(a, b, c, d e); | ||
| -^ | ||
| | | ||
| help: missing comma here | ||
|
||
error: no rules expected the token `d` | ||
--> $DIR/missing-comma.rs:26:18 | ||
| | ||
LL | foo!(a, b, c d, e); | ||
| -^ | ||
| | | ||
| help: missing comma here | ||
|
||
error: no rules expected the token `d` | ||
--> $DIR/missing-comma.rs:28:18 | ||
| | ||
LL | foo!(a, b, c d e); | ||
| ^ | ||
|
||
error: aborting due to 5 previous errors | ||
|