Closed
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
Area: Messages for errors, warnings, and lintsArea: The lexing & parsing of Rust source code to an ASTCategory: An issue proposing an enhancement or a PR with one.Diagnostics: Confusing error or lint; hard to understand for new users.Relevant to the compiler team, which will review and decide on the PR/issue.