Add lint when comparing floats in an array

Finishes #4277
This commit is contained in:
briankabiro 2019-07-31 14:52:12 +03:00 committed by Marcin Serwin
parent c25f26d4ca
commit d4409350dc

View file

@ -498,8 +498,14 @@ fn is_signum(cx: &LateContext<'_, '_>, expr: &Expr<'_>) -> bool {
false
}
fn is_float(cx: &LateContext<'_, '_>, expr: &Expr<'_>) -> bool {
matches!(walk_ptrs_ty(cx.tables.expr_ty(expr)).kind, ty::Float(_))
fn is_float(cx: &LateContext<'_, '_>, expr: &Expr) -> bool {
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<'_>) {