Skip to content

Uplift clippy::double_neg into rustc #82987

Closed
@rbtcollins

Description

@rbtcollins

See this https://dtolnay.github.io/rust-quiz/17

I agree with our position on the inclusion of --/++ in Rust, however currently we just silently treat --i as -(-i), which means that users who are coming from C++ and C get absolutely no warning that their code is going to do something entirely different than they expect - and there's arguably no use case for an unbracketed - -i : its the same as a literal i.

I expected to see this happen:

A warning, or an error: "attempt to use unsupported post-increment operator. Use +=1 instead". Or something like that.

Instead, this happened: explanation

Meta

I'm not sure what rustc version the rust-quiz website is running.

rustc --version --verbose:

<version>
Backtrace

<backtrace>

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.C-feature-requestCategory: A feature request, i.e: not implemented / a PR.D-newcomer-roadblockDiagnostics: 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.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions