about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAda Alakbarova <ada.alakbarova@proton.me>2025-08-19 23:46:47 +0200
committerAda Alakbarova <ada.alakbarova@proton.me>2025-08-22 15:03:13 +0200
commite6833462eb00a5aaa60c9be3472448cba600b404 (patch)
treee28463d692ce9d5dc5c07eb204c4dd7bdebed84d
parentabb89608af8e5eae6f89a9b06bd9b5a10ca2afe9 (diff)
downloadrust-e6833462eb00a5aaa60c9be3472448cba600b404.tar.gz
rust-e6833462eb00a5aaa60c9be3472448cba600b404.zip
misc: destruct `args` directly
avoids bounds checks
-rw-r--r--clippy_utils/src/higher.rs12
1 files changed, 6 insertions, 6 deletions
diff --git a/clippy_utils/src/higher.rs b/clippy_utils/src/higher.rs
index 9db18f66e9a..425de63ae19 100644
--- a/clippy_utils/src/higher.rs
+++ b/clippy_utils/src/higher.rs
@@ -288,14 +288,14 @@ impl<'a> VecArgs<'a> {
             && is_expn_of(fun.span, sym::vec).is_some()
             && let Some(fun_def_id) = cx.qpath_res(qpath, fun.hir_id).opt_def_id()
         {
-            return match (cx.tcx.get_diagnostic_name(fun_def_id), args.len()) {
-                (Some(sym::vec_from_elem), 2) => {
+            return match (cx.tcx.get_diagnostic_name(fun_def_id), args) {
+                (Some(sym::vec_from_elem), [elem, size]) => {
                     // `vec![elem; size]` case
-                    Some(VecArgs::Repeat(&args[0], &args[1]))
+                    Some(VecArgs::Repeat(elem, size))
                 },
-                (Some(sym::slice_into_vec), 1) => {
+                (Some(sym::slice_into_vec), [slice]) => {
                     // `vec![a, b, c]` case
-                    if let ExprKind::Call(_, [arg]) = &args[0].kind
+                    if let ExprKind::Call(_, [arg]) = slice.kind
                         && let ExprKind::Array(args) = arg.kind
                     {
                         Some(VecArgs::Vec(args))
@@ -303,7 +303,7 @@ impl<'a> VecArgs<'a> {
                         None
                     }
                 },
-                (Some(sym::vec_new), 0) => Some(VecArgs::Vec(&[])),
+                (Some(sym::vec_new), []) => Some(VecArgs::Vec(&[])),
                 _ => None,
             };
         }