Skip to content

Commit 99445f9

Browse files
committed
add lint when comparing floats in an array
Finishes rust-lang#4277
1 parent c3e9136 commit 99445f9

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

clippy_lints/src/misc.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,8 @@ fn is_signum(cx: &LateContext<'_, '_>, expr: &Expr) -> bool {
519519
}
520520

521521
fn is_float(cx: &LateContext<'_, '_>, expr: &Expr) -> bool {
522-
matches!(walk_ptrs_ty(cx.tables.expr_ty(expr)).sty, ty::Float(_))
522+
let value = walk_ptrs_ty(cx.tables.expr_ty(expr)).sty;
523+
matches!(value, ty::Float(_)) || matches!(value, ty::Array(ty::Float, _))
523524
}
524525

525526
fn check_to_owned(cx: &LateContext<'_, '_>, expr: &Expr, other: &Expr) {

0 commit comments

Comments
 (0)