1 use clippy_utils::consts::{constant, Constant};
2 use clippy_utils::diagnostics::span_lint;
3 use clippy_utils::in_constant;
4 use rustc_hir::{BinOpKind, Expr};
5 use rustc_lint::LateContext;
9 pub(super) fn check(cx: &LateContext<'_>, e: &Expr<'_>, op: BinOpKind, lhs: &Expr<'_>, rhs: &Expr<'_>) {
10 if op.is_comparison() && !in_constant(cx, e.hir_id) && (is_nan(cx, lhs) || is_nan(cx, rhs)) {
15 "doomed comparison with `NAN`, use `{f32,f64}::is_nan()` instead",
20 fn is_nan(cx: &LateContext<'_>, e: &Expr<'_>) -> bool {
21 if let Some((value, _)) = constant(cx, cx.typeck_results(), e) {
23 Constant::F32(num) => num.is_nan(),
24 Constant::F64(num) => num.is_nan(),