INVALID_NAN_COMPARISONS in rustc_lint::types - Rust
Description: The `invalid_nan_comparisons` lint checks comparison with `f32::NAN` or `f64::NAN` as one of the operand.

Skip to main content

## INVALID_NAN_COMPARISONS

# Static INVALID_NAN_COMPARISONS

Source

    static INVALID_NAN_COMPARISONS: &Lint

Expand description

The `invalid_nan_comparisons` lint checks comparison with `f32::NAN` or `f64::NAN` as one of the operand.

#### §Example

    let a = 2.3f32;
    if a == f32::NAN {}

{{produces}}

#### §Explanation

NaN does not compare meaningfully to anything – not even itself – so those comparisons are always false.