Skip to content

Commit 1d6754b

Browse files
committed
check f16 and f128 in float_equality_without_abs
1 parent 506411d commit 1d6754b

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

clippy_lints/src/operators/float_equality_without_abs.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ pub(crate) fn check<'tcx>(
2424
_ => return,
2525
};
2626

27+
let sym_epsilon = [sym::f16_epsilon, sym::f32_epsilon, sym::f64_epsilon, sym::f128_epsilon];
28+
2729
if let ExprKind::Binary(
2830
// left hand side is a subtraction
2931
Spanned {
@@ -34,10 +36,10 @@ pub(crate) fn check<'tcx>(
3436
val_r,
3537
) = lhs.kind
3638

37-
// right hand side matches either f32::EPSILON or f64::EPSILON
39+
// right hand side matches _::EPSILON
3840
&& let ExprKind::Path(ref epsilon_path) = rhs.kind
3941
&& let Res::Def(DefKind::AssocConst, def_id) = cx.qpath_res(epsilon_path, rhs.hir_id)
40-
&& ([sym::f32_epsilon, sym::f64_epsilon].into_iter().any(|sym| cx.tcx.is_diagnostic_item(sym, def_id)))
42+
&& (sym_epsilon.into_iter().any(|sym| cx.tcx.is_diagnostic_item(sym, def_id)))
4143

4244
// values of the subtractions on the left hand side are of the type float
4345
&& let t_val_l = cx.typeck_results().expr_ty(val_l)

0 commit comments

Comments
 (0)