-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-parserArea: The lexing & parsing of Rust source code to an ASTArea: The lexing & parsing of Rust source code to an ASTC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.D-newcomer-roadblockDiagnostics: Confusing error or lint; hard to understand for new users.Diagnostics: Confusing error or lint; hard to understand for new users.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
Given the following code in the playground:
fn main() {
let i = 0;
i++;
}
The current output is:
Compiling playground v0.0.1 (/playground)
error: expected expression, found `+`
--> src/main.rs:3:7
|
3 | i++;
| ^ expected expression
error: aborting due to previous error
error: could not compile `playground`
To learn more, run the command again with --verbose.
I think the message for errors involving ++
or --
should understand that the user is trying to use an operator which doesn't exist in Rust and suggest an idiomatic way to do the increment/decrement operation.
Explanation
Languages like C, Java or Javascript use ++
and --
to increment or decrement integer variables, respectively. As Rust does not support them, it may be good to add an specific diagnostic for those cases, suggesting the user to use something like i += 1
instead.
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-parserArea: The lexing & parsing of Rust source code to an ASTArea: The lexing & parsing of Rust source code to an ASTC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.D-newcomer-roadblockDiagnostics: Confusing error or lint; hard to understand for new users.Diagnostics: Confusing error or lint; hard to understand for new users.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.