X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Ftools%2Fclippy%2Fclippy_lints%2Fsrc%2Fmethods%2Fiter_cloned_collect.rs;h=30d56113c6c102af9e81b9a9c86857bb491406f3;hb=7fab8a4016e083d43e181b6da71d6a45ac7e7d3b;hp=dd4ef6e4b58ee72ede7975985c9c76bfa0cb1cec;hpb=0888c6dc7804ac5944d705c6aca1fdecbbefba82;p=rust.git diff --git a/src/tools/clippy/clippy_lints/src/methods/iter_cloned_collect.rs b/src/tools/clippy/clippy_lints/src/methods/iter_cloned_collect.rs index dd4ef6e4b58..30d56113c6c 100644 --- a/src/tools/clippy/clippy_lints/src/methods/iter_cloned_collect.rs +++ b/src/tools/clippy/clippy_lints/src/methods/iter_cloned_collect.rs @@ -9,7 +9,7 @@ use super::ITER_CLONED_COLLECT; -pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &hir::Expr<'_>, recv: &'tcx hir::Expr<'_>) { +pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, method_name: &str, expr: &hir::Expr<'_>, recv: &'tcx hir::Expr<'_>) { if_chain! { if is_type_diagnostic_item(cx, cx.typeck_results().expr_ty(expr), sym::Vec); if let Some(slice) = derefs_to_slice(cx, recv, cx.typeck_results().expr_ty(recv)); @@ -20,8 +20,8 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &hir::Expr<'_>, recv: &' cx, ITER_CLONED_COLLECT, to_replace, - "called `iter().cloned().collect()` on a slice to create a `Vec`. Calling `to_vec()` is both faster and \ - more readable", + &format!("called `iter().{}().collect()` on a slice to create a `Vec`. Calling `to_vec()` is both faster and \ + more readable", method_name), "try", ".to_vec()".to_string(), Applicability::MachineApplicable,