Skip to content

Commit

Permalink
Add lint when comparing floats in an array
Browse files Browse the repository at this point in the history
  • Loading branch information
briankabiro committed Sep 17, 2019
1 parent c3e9136 commit 11197c5
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion clippy_lints/src/misc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,13 @@ fn is_signum(cx: &LateContext<'_, '_>, expr: &Expr) -> bool {
}

fn is_float(cx: &LateContext<'_, '_>, expr: &Expr) -> bool {
matches!(walk_ptrs_ty(cx.tables.expr_ty(expr)).sty, ty::Float(_))
let value = &walk_ptrs_ty(cx.tables.expr_ty(expr)).sty;

if let ty::Array(arr_ty, _) = value {
return matches!(arr_ty.sty, ty::Float(_));
};

matches!(value, ty::Float(_))
}

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

0 comments on commit 11197c5

Please sign in to comment.