Misleading error for missing comma/semicolon in array literal #96791
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
A-suggestion-diagnostics
Area: Suggestions generated by the compiler applied by `cargo fix`
D-invalid-suggestion
Diagnostics: A structured suggestion resulting in incorrect code.
D-papercut
Diagnostics: An error or lint that needs small tweaks.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Given the following code: Playground
The current output is:
Ideally the output should look like:
The error implies that
;
is the only valid token at the end of the second line, and that the third line is being considered a separate statement from the second line, probably due to a consequence of the fault-tolerant parsing machinery.Reasonable output is given when the newline is removed or there is more than 2 elements:
This should be fixed because it is confusing in less clear situations such as the following, especially where someone might expect the comma to be implicit due to the behaviour of
match
.This happens in every edition and on both stable and nightly.
The text was updated successfully, but these errors were encountered: