Fix NAN comparison lint to use assoc NAN

This commit is contained in:
Linus Färnstrand
2020-04-06 23:53:11 +02:00
parent d342cee787
commit 0b4ee9a649
3 changed files with 64 additions and 65 deletions

View File

@@ -57,10 +57,9 @@ declare_clippy_lint! {
///
/// **Example:**
/// ```rust
/// # use core::f32::NAN;
/// # let x = 1.0;
///
/// if x == NAN { }
/// if x == f32::NAN { }
/// ```
pub CMP_NAN,
correctness,
@@ -457,7 +456,7 @@ fn check_nan(cx: &LateContext<'_, '_>, expr: &Expr<'_>, cmp_expr: &Expr<'_>) {
cx,
CMP_NAN,
cmp_expr.span,
"doomed comparison with `NAN`, use `std::{f32,f64}::is_nan()` instead",
"doomed comparison with `NAN`, use `{f32,f64}::is_nan()` instead",
);
}
}