parser should recover from seeing ,
when ;
is expected
#48160
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
A-parser
Area: The parsing of Rust source code to an AST
C-enhancement
Category: An issue proposing an enhancement or a PR with one.
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.
Right now, if
rustc
is parsing a function body and sees a,
when it expected a;
, it will give up on parsing the rest of the current function body.Meanwhile, later phases of the compiler still run. Which means, for example, if the remainder of that erroneous function body contains the sole references to certain imports, then you get false warnings about those imports being unused.
Here is a concrete example (playground):
which yields the following diagnostic output on nightly and beta:
This seems to affect the current nightly and beta, but not stable (I.e., the stable channel just presents the parse error, not the erroneous lint about the supposedly unused import.)
The text was updated successfully, but these errors were encountered: