Skip to content

Commit e1edea2

Browse files
committed
Cleanup
1 parent dc76dcb commit e1edea2

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

clippy_lints/src/methods/iter_overeager_cloned.rs

+5-7
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,8 @@ pub(super) fn check<'tcx>(
1919
name: &str,
2020
map_arg: &[hir::Expr<'_>],
2121
) {
22-
let recv_ty = cx.typeck_results().expr_ty_adjusted(recv);
2322
// Check if it's iterator and get type associated with `Item`.
24-
let inner_ty = match get_iterator_item_ty(cx, recv_ty) {
23+
let inner_ty = match get_iterator_item_ty(cx, cx.typeck_results().expr_ty_adjusted(recv)) {
2524
Some(ty) => ty,
2625
_ => return,
2726
};
@@ -31,7 +30,7 @@ pub(super) fn check<'tcx>(
3130
_ => return,
3231
};
3332

34-
let (lint, preserve_clopned) = match name {
33+
let (lint, preserve_cloned) = match name {
3534
"count" => (REDUNDANT_CLONE, false),
3635
_ => (ITER_OVEREAGER_CLONED, true),
3736
};
@@ -43,10 +42,9 @@ pub(super) fn check<'tcx>(
4342
wildcard_params,
4443
name,
4544
wildcard_params,
46-
preserve_clopned.then(|| ".cloned()").unwrap_or_default(),
45+
preserve_cloned.then(|| ".cloned()").unwrap_or_default(),
4746
);
4847

49-
let iter_snippet = snippet(cx, recv.span, "..");
5048
span_lint_and_sugg(
5149
cx,
5250
lint,
@@ -55,10 +53,10 @@ pub(super) fn check<'tcx>(
5553
"try this",
5654
format!(
5755
"{}.{}({}){}",
58-
iter_snippet,
56+
snippet(cx, recv.span, ".."),
5957
name,
6058
map_arg.iter().map(|a| snippet(cx, a.span, "..")).join(", "),
61-
preserve_clopned.then(|| ".cloned()").unwrap_or_default(),
59+
preserve_cloned.then(|| ".cloned()").unwrap_or_default(),
6260
),
6361
Applicability::MachineApplicable,
6462
);

0 commit comments

Comments
 (0)