parser: [elem; count]
is strong signal that an array literal was intended
#107518
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
A-parser
Area: The parsing of Rust source code to an AST
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Code
Current output
Desired output
that is, In addition to the current parser error, it would be nice if the diagnostic included a note or suggestion that while
[elem; count]
can be used to construct an array literal, the tokens above cannot be an array literal because of the immediately preceding identifier.(I suppose in an ideal world it would even suggest adding the parentheses to turn it into a function call, but that would require more context than I think we can expect to have at this point in the context of where the parser is.)
Rationale and extra context
I'll be honest, I left out the call parentheses by accident, and then kept staring at the rustc error message trying to understand why it wouldn't accept a semi-colon there.
Other cases
No response
Anything else?
No response
The text was updated successfully, but these errors were encountered: