Skip to content

Warn for unmatchable NaN case. #6804

Closed
Closed
@cscott

Description

@cscott

Rust already warns for unmatchable cases in a match expression. Since NaN != NaN, any use of NaN (f64, float, other?) in a match pattern should generate the same unmatchable case warning.

If the reader is curious, the proper way to match NaN is something like:

match x {
    x if f64::isNaN(x) => { ... }
...
}

For bonus points, the unmatchable case warning for NaN could mention this: "use isNaN in a guard expression instead".

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions