-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-parserArea: The lexing & parsing of Rust source code to an ASTArea: The lexing & parsing of Rust source code to an AST
Description
See #56897 (comment).
The format!
macro claims that it expects ,
when failing to parse a format string argument, but it actually accepts all tokens that make up expressions in that position. The simplest fix would be to use expect(&token::Comma)
, but that causes parsing errors directly after the format string to claim that expression tokens are expected in that position are accepted, when they are not.
In other words, it would be nice to get diagnostics like this:
-error: expected token: `,`
+error: expected one of `,`, `.`, `?`, or an operator, found `1`
--> $DIR/bad-format-args.rs:4:19
|
LL | format!("", 1 1); //~ ERROR expected token: `,`
- | ^
+ | ^ expected one of `,`, `.`, `?`, or an operator here
while avoiding getting diagnostics like this:
-error: expected token: `,`
+error: expected one of `,`, `.`, `?`, or an operator, found `1`
--> $DIR/bad-format-args.rs:3:16
|
LL | format!("" 1); //~ ERROR expected token: `,`
- | ^
+ | ^ expected one of `,`, `.`, `?`, or an operator here
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-parserArea: The lexing & parsing of Rust source code to an ASTArea: The lexing & parsing of Rust source code to an AST