Skip to content

Commit c65099f

Browse files
committed
extract a condition into a function.
1 parent fe0aab9 commit c65099f

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
@@ -44,12 +44,7 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'_>, ite
4444
);
4545
}
4646
}
47-
} else if is_type_diagnostic_item(cx, cx.typeck_results().expr_ty(caller_expr), sym::vec_type)
48-
|| matches!(
49-
&cx.typeck_results().expr_ty(caller_expr).peel_refs().kind(),
50-
ty::Array(_, _)
51-
)
52-
{
47+
} else if is_vec_or_array(cx, caller_expr) {
5348
// caller is a Vec or an Array
5449
let mut applicability = Applicability::MachineApplicable;
5550
span_lint_and_sugg(
@@ -66,3 +61,8 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'_>, ite
6661
);
6762
}
6863
}
64+
65+
fn is_vec_or_array<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'_>) -> bool {
66+
is_type_diagnostic_item(cx, cx.typeck_results().expr_ty(expr), sym::vec_type)
67+
|| matches!(&cx.typeck_results().expr_ty(expr).peel_refs().kind(), ty::Array(_, _))
68+
}

0 commit comments

Comments
 (0)