Skip to content

Commit 35b1453

Browse files
committed
map_identity checks for unneeded .map_err
1 parent e511476 commit 35b1453

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

clippy_lints/src/methods/map_identity.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ pub(super) fn check(
1313
expr: &hir::Expr<'_>,
1414
caller: &hir::Expr<'_>,
1515
map_arg: &hir::Expr<'_>,
16+
name: &str,
1617
_map_span: Span,
1718
) {
1819
let caller_ty = cx.typeck_results().expr_ty(caller);
@@ -29,7 +30,7 @@ pub(super) fn check(
2930
MAP_IDENTITY,
3031
sugg_span,
3132
"unnecessary map of the identity function",
32-
"remove the call to `map`",
33+
&format!("remove the call to `{}`", name),
3334
String::new(),
3435
Applicability::MachineApplicable,
3536
)

clippy_lints/src/methods/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2334,7 +2334,7 @@ fn check_methods<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>, msrv: Optio
23342334
}
23352335
}
23362336
},
2337-
("map", [m_arg]) => {
2337+
(name @ ("map" | "map_err"), [m_arg]) => {
23382338
if let Some((name, [recv2, args @ ..], span2)) = method_call(recv) {
23392339
match (name, args) {
23402340
("as_mut", []) => option_as_ref_deref::check(cx, expr, recv2, m_arg, true, msrv),
@@ -2346,7 +2346,7 @@ fn check_methods<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>, msrv: Optio
23462346
_ => {},
23472347
}
23482348
}
2349-
map_identity::check(cx, expr, recv, m_arg, span);
2349+
map_identity::check(cx, expr, recv, m_arg, name, span);
23502350
},
23512351
("map_or", [def, map]) => option_map_or_none::check(cx, expr, recv, def, map),
23522352
(name @ "next", args @ []) => {

0 commit comments

Comments
 (0)