Skip to content

False positive: nonminimal_bool for types which implement PartialOrd but not Ord #2626

@0ndorio

Description

@0ndorio

The nonminimal_bool lint suggests to minimize the following expression !(a <= b) into a > b. While this is a proper improvement for types implementing Ord it doesn't fit for all types of PartialOrd and would actually change the result of the expression as it means 'greater or incomparable' and not just 'greater'.

Maybe clippy should instead suggest to rewrite the expression using the partial_cmp() method and a match statement.

Example:
https://play.rust-lang.org/?gist=25676640c1f106e733d008dc224a9d49&version=stable

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thing

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions