diff options
| author | Philipp Krones <hello@philkrones.com> | 2024-03-21 22:05:29 +0100 |
|---|---|---|
| committer | Philipp Krones <hello@philkrones.com> | 2024-03-21 22:05:29 +0100 |
| commit | 7d42d736c53dce04ec02c2ffdf876d86901de2e7 (patch) | |
| tree | c98b05e5982d9f5726f9e88d411b5662109108d4 /clippy_lints/src/methods/map_clone.rs | |
| parent | 76096efb48d79ee5d3434d31285828d15a50b9c7 (diff) | |
| parent | 443f459f98841001b2c2041adda05b9318f44b24 (diff) | |
Merge remote-tracking branch 'upstream/master' into rustup
Diffstat (limited to 'clippy_lints/src/methods/map_clone.rs')
| -rw-r--r-- | clippy_lints/src/methods/map_clone.rs | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/clippy_lints/src/methods/map_clone.rs b/clippy_lints/src/methods/map_clone.rs index 27e17b43b01..c3c7a3a0033 100644 --- a/clippy_lints/src/methods/map_clone.rs +++ b/clippy_lints/src/methods/map_clone.rs @@ -86,8 +86,11 @@ pub(super) fn check(cx: &LateContext<'_>, e: &hir::Expr<'_>, recv: &hir::Expr<'_ } } }, - hir::ExprKind::Call(call, [_]) => { - if let hir::ExprKind::Path(qpath) = call.kind { + hir::ExprKind::Call(call, args) => { + if let hir::ExprKind::Path(qpath) = call.kind + && let [arg] = args + && ident_eq(name, arg) + { handle_path(cx, call, &qpath, e, recv); } }, @@ -118,7 +121,9 @@ fn handle_path( if let ty::Adt(_, args) = cx.typeck_results().expr_ty(recv).kind() && let args = args.as_slice() && let Some(ty) = args.iter().find_map(|generic_arg| generic_arg.as_type()) - && ty.is_ref() + && let ty::Ref(_, ty, Mutability::Not) = ty.kind() + && let ty::FnDef(_, lst) = cx.typeck_results().expr_ty(arg).kind() + && lst.iter().all(|l| l.as_type() == Some(*ty)) { lint_path(cx, e.span, recv.span, is_copy(cx, ty.peel_refs())); } |
