Skip to content

float_cmp: ignore when comparing with constant? #1142

Closed
@birkenfeld

Description

@birkenfeld

Consider:

const ONE: f32 = 1.0;
fn main() {
    let v = 0.9;
    let _ = v == ONE;
}

These are probably cases where you want to check for the exact constant, because it is a common argument, a sentinel value, or an integer converted to floating-point due to external APIs, etc.

There is already a special case for 0 and +/-inf, but I'd add a case for this situation too.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-enhancementCategory: Enhancement of lints, like adding more cases or adding help messagesgood first issueThese issues are a good way to get started with Clippy

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions