Skip to content

Commit d0f93c1

Browse files
committed
refactor: get the required variables with MethodCall
1 parent e47c5b0 commit d0f93c1

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

clippy_lints/src/get_first.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,11 @@ declare_lint_pass!(GetFirst => [GET_FIRST]);
4040
impl<'tcx> LateLintPass<'tcx> for GetFirst {
4141
fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'_>) {
4242
if_chain! {
43-
if let hir::ExprKind::MethodCall(_, expr_args, _) = &expr.kind;
43+
if let hir::ExprKind::MethodCall(_, [struct_calling_on, method_arg], _) = &expr.kind;
4444
if let Some(expr_def_id) = cx.typeck_results().type_dependent_def_id(expr.hir_id);
45-
if match_def_path(cx, expr_def_id, &paths::SLICE_GET) && expr_args.len() == 2;
45+
if match_def_path(cx, expr_def_id, &paths::SLICE_GET);
4646

47-
if let Some(struct_calling_on) = expr_args.get(0);
4847
if let Some(_) = is_slice_of_primitives(cx, struct_calling_on);
49-
50-
if let Some(method_arg) = expr_args.get(1);
5148
if let hir::ExprKind::Lit(Spanned { node: LitKind::Int(0, _), .. }) = method_arg.kind;
5249

5350
then {

0 commit comments

Comments
 (0)