Skip to content

Commit

Permalink
add lint when comparing floats in an array
Browse files Browse the repository at this point in the history
Finishes #4277
  • Loading branch information
briankabiro committed Aug 27, 2019
1 parent c3e9136 commit dc53b28
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion clippy_lints/src/misc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,9 @@ 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;

matches!(value, ty::Array(arr_ty, _)) && matches!(value, ty::Float(_)) || matches!(value, ty::Float(_))
}

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

0 comments on commit dc53b28

Please sign in to comment.