Skip to content

Lint wrong integer range comparisons #1110

@Boddlnagg

Description

@Boddlnagg

I don't know if an issue already exists for something like this, but at least I couldn't find one:
I suggest to add a lint that checks for conditions such as

  • i > A || i < B where A and B are integer literals (or constants?) with AB (always true)
  • i < A && i > B where A and B are integer literals (or constants?) with AB (always false)

After rust-lang/rust#32311 is stabilized, clippy could also suggest to use Range::contains.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lintArea: New lintsE-mediumCall for participation: Medium difficulty level problem and requires some initial experience.T-middleType: Probably requires verifiying types

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions