Skip to content

Lint against --foo when foo is a numeric binding #88669

Closed
@estebank

Description

@estebank

As noted in #88553 (comment), let x = --y; is syntactically valid as a double negation, but it looks like C's pre-decrement. We should lint against it and suggest both removing the -- or writing y -= 1; let x = y;.

pre-increment, post-increment and post-decrement are not likely to confuse people too much because they are syntax errors, but we might also want to modify the parser to detect them specifically and provide a structured suggestion for appropriate code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.A-parserArea: The lexing & parsing of Rust source code to an ASTD-papercutDiagnostics: An error or lint that needs small tweaks.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.P-lowLow priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions