Skip to content

Commit fbe8261

Browse files
committed
extract a condition into a function.
1 parent 82fd2d1 commit fbe8261

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

clippy_lints/src/methods/iter_next_slice.rs

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

0 commit comments

Comments
 (0)