-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
odd suggestion for comma typo #72253
Comments
This is because the error recovery tries to figure out if you typoed something when trying to write ; to end an expression. This is probably easy to fix. |
@rustbot claim |
Thoughts about the better approach?:
vs.
|
I would prefer something closer to what we already see in other syntax errors:
We are not afraid of using vertical space to make errors clearer, but that vertical space still comes at a premium, as does verbosity. We try to lean towards the tersest possible output that can still convey the concept to the broadest set of people. |
confusing diagnostics, issue rust-lang#72253 add test for confusing error message, issue-72253 remove is_multiline check, refactor to self.expect(&token:Semi) update issue-72253 tests return Ok
Fix confusing error message for comma typo in multiline statement Fixes rust-lang#72253. Expands on the issue with a colon typo check. r? @estebank cc @ehuss
In an obscure situation with a typo (where there is a comma instead of a period), rustc will suggest replacing the comma with a semicolon, which will fail to compile.
Produces the following error and suggestion:
Some observations:
I would expect this to provide the same error if it is all on one line ("expected one of
.
,;
,?
, or an operator"), possibly with a "maybe incorrect" suggestion to replace it with a period (maybe only if the following character is not whitespace?).Note: Feel free to close this. This is really obscure, and I suspect it is not trivial to change, and it is fairly obvious what is wrong. I just thought it was strange, and I was doubly puzzled that the indentation mattered.
Meta
rustc 1.45.0-nightly (9912925 2020-05-10)
The text was updated successfully, but these errors were encountered: