Skip to content

Commit 96855e3

Browse files
committed
extract a condition into a function.
1 parent ad9bdc5 commit 96855e3

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

clippy_lints/src/methods/iter_next_slice.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,7 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'_>, ite
4747
);
4848
}
4949
}
50-
} else if is_type_diagnostic_item(cx, cx.typeck_results().expr_ty(caller_expr), sym::vec_type)
51-
|| matches!(
52-
&cx.typeck_results().expr_ty(caller_expr).peel_refs().kind(),
53-
ty::Array(_, _)
54-
)
55-
{
50+
} else if is_vec_or_array(cx, caller_expr) {
5651
// caller is a Vec or an Array
5752
let mut applicability = Applicability::MachineApplicable;
5853
span_lint_and_sugg(
@@ -69,3 +64,8 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'_>, ite
6964
);
7065
}
7166
}
67+
68+
fn is_vec_or_array<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'_>) -> bool {
69+
is_type_diagnostic_item(cx, cx.typeck_results().expr_ty(expr), sym::vec_type)
70+
|| matches!(&cx.typeck_results().expr_ty(expr).peel_refs().kind(), ty::Array(_, _))
71+
}

0 commit comments

Comments
 (0)