Closed
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