about summary refs log tree commit diff
diff options
context:
space:
mode:
authorkyoto7250 <50972773+kyoto7250@users.noreply.github.com>2022-05-25 09:11:29 +0900
committerkyoto7250 <50972773+kyoto7250@users.noreply.github.com>2022-05-25 09:11:29 +0900
commitd0f93c12a2a6f0d693507ff6325fed62720e616b (patch)
tree16c31c0dcc35d3ce530bc20bfd6b917b6124d4bd
parente47c5b0e035c556947fcf3485fd2d1823ed1d1b1 (diff)
downloadrust-d0f93c12a2a6f0d693507ff6325fed62720e616b.tar.gz
rust-d0f93c12a2a6f0d693507ff6325fed62720e616b.zip
refactor: get the required variables with MethodCall
-rw-r--r--clippy_lints/src/get_first.rs7
1 files changed, 2 insertions, 5 deletions
diff --git a/clippy_lints/src/get_first.rs b/clippy_lints/src/get_first.rs
index 0f26c19c49e..0748ab45252 100644
--- a/clippy_lints/src/get_first.rs
+++ b/clippy_lints/src/get_first.rs
@@ -40,14 +40,11 @@ declare_lint_pass!(GetFirst => [GET_FIRST]);
 impl<'tcx> LateLintPass<'tcx> for GetFirst {
     fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'_>) {
         if_chain! {
-            if let hir::ExprKind::MethodCall(_, expr_args, _) = &expr.kind;
+            if let hir::ExprKind::MethodCall(_, [struct_calling_on, method_arg], _) = &expr.kind;
             if let Some(expr_def_id) = cx.typeck_results().type_dependent_def_id(expr.hir_id);
-            if match_def_path(cx, expr_def_id, &paths::SLICE_GET) && expr_args.len() == 2;
+            if match_def_path(cx, expr_def_id, &paths::SLICE_GET);
 
-            if let Some(struct_calling_on) = expr_args.get(0);
             if let Some(_) = is_slice_of_primitives(cx, struct_calling_on);
-
-            if let Some(method_arg) = expr_args.get(1);
             if let hir::ExprKind::Lit(Spanned { node: LitKind::Int(0, _), .. }) = method_arg.kind;
 
             then {