Consider removing a non-existing semicolon #81098
Labels
A-suggestion-diagnostics
Area: Suggestions generated by the compiler applied by `cargo fix`
C-bug
Category: This is a bug.
D-invalid-suggestion
Diagnostics: A structured suggestion resulting in incorrect code.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
I tried this code:
I expected to see this happen: An error explaining that () does not impl Display (although a different message would be nice, cf #54771).
Instead, this happened: I got that error, but I also got a suggestion to remove a semicolon. As you can see, this program does not contain any semicolons to remove.
Of course, I understand why the suggestion exists, but rustc should probably check to see if a semicolon exists before suggesting to remove it. For bonus points, rustc should find the semicolon correctly in this slightly modified program. (Currently it still points at
why
's}
.)Here is perhaps a worse variant of the same issue:
Here the suggestion is to remove the semicolon after the
WHY
item, which is now a "syntactically correct suggestion" so to speak (i.e., the "remove a semicolon" is now pointing at an actual semicolon)... but applying it does not result in a syntactically correct program.The text was updated successfully, but these errors were encountered: