about summary refs log tree commit diff
path: root/clippy_lints/src
diff options
context:
space:
mode:
authorScott Gerring <scott@scottgerring.com>2024-12-17 18:14:34 +0100
committerScott Gerring <scott@scottgerring.com>2024-12-17 18:14:34 +0100
commit8fe39b276f56863e77bf4b7c3192a339a8a1ec58 (patch)
treed870ca0465d1d6be1bc406a7724590adb4ebbac1 /clippy_lints/src
parent0f9cc8d58b82ff6d6b9380a10a8cbed22734eac0 (diff)
downloadrust-8fe39b276f56863e77bf4b7c3192a339a8a1ec58.tar.gz
rust-8fe39b276f56863e77bf4b7c3192a339a8a1ec58.zip
Change unnecessary_iter_cloned to use multipart_suggestion
Diffstat (limited to 'clippy_lints/src')
-rw-r--r--clippy_lints/src/methods/unnecessary_iter_cloned.rs16
1 files changed, 8 insertions, 8 deletions
diff --git a/clippy_lints/src/methods/unnecessary_iter_cloned.rs b/clippy_lints/src/methods/unnecessary_iter_cloned.rs
index 029704882dd..671c189a98e 100644
--- a/clippy_lints/src/methods/unnecessary_iter_cloned.rs
+++ b/clippy_lints/src/methods/unnecessary_iter_cloned.rs
@@ -6,6 +6,7 @@ use clippy_utils::ty::{get_iterator_item_ty, implements_trait};
 use clippy_utils::visitors::for_each_expr_without_closures;
 use clippy_utils::{can_mut_borrow_both, fn_def_id, get_parent_expr, path_to_local};
 use core::ops::ControlFlow;
+use itertools::Itertools;
 use rustc_errors::Applicability;
 use rustc_hir::def_id::DefId;
 use rustc_hir::{BindingMode, Expr, ExprKind, Node, PatKind};
@@ -122,14 +123,13 @@ pub fn check_for_loop_iter(
                 } else {
                     Applicability::MachineApplicable
                 };
-                diag.span_suggestion(expr.span, "use", snippet.to_owned(), applicability);
-                if !references_to_binding.is_empty() {
-                    diag.multipart_suggestion(
-                        "remove any references to the binding",
-                        references_to_binding,
-                        applicability,
-                    );
-                }
+
+                let combined = references_to_binding
+                    .into_iter()
+                    .chain(vec![(expr.span, snippet.to_owned())])
+                    .collect_vec();
+
+                diag.multipart_suggestion("remove any references to the binding", combined, applicability);
             },
         );
         return true;