Skip to content

Commit d67697f

Browse files
committed
fix bugs
1 parent c358de9 commit d67697f

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

clippy_lints/src/methods/map_then_identity_transformer.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ pub(super) fn check<'tcx>(
4040
)
4141
}
4242

43-
// In a given closure `|.., x| y`, examine if `x` is referenced just exactly once in `y`.
43+
// On a given closure `|.., x| y`, checks if `x` is referenced just exactly once in `y` and returns
44+
// the span of `x`
4445
fn refd_param_span<'tcx>(cx: &LateContext<'tcx>, clos_body_id: &BodyId) -> Option<Span> {
4546
if_chain! {
4647
let clos_body = cx.tcx.hir().body(*clos_body_id);

clippy_lints/src/methods/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2288,7 +2288,7 @@ fn check_methods<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>, msrv: Optio
22882288
zst_offset::check(cx, expr, recv);
22892289
},
22902290
(name @ ("all" | "any" | "find" | "find_map" | "position"), [arg]) => {
2291-
if let Some((name2 @ ("flat_map" | "filter_map" | "map"), [_, arg2], span2)) = method_call(recv) {
2291+
if let Some((name2 @ "map", [_, arg2], span2)) = method_call(recv) {
22922292
map_then_identity_transformer::check(cx, span2, name2, arg2, name, arg);
22932293
}
22942294
},
@@ -2334,14 +2334,14 @@ fn check_methods<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>, msrv: Optio
23342334
extend_with_drain::check(cx, expr, recv, arg);
23352335
},
23362336
(name @ "filter_map", [arg]) => {
2337-
if let Some((name2 @ ("flat_map" | "filter_map" | "map"), [_, arg2], span2)) = method_call(recv) {
2337+
if let Some((name2 @ "map", [_, arg2], span2)) = method_call(recv) {
23382338
map_then_identity_transformer::check(cx, span2, name2, arg2, name, arg);
23392339
}
23402340
unnecessary_filter_map::check(cx, expr, arg);
23412341
filter_map_identity::check(cx, expr, arg, span);
23422342
},
23432343
(name @ "flat_map", [arg]) => {
2344-
if let Some((name2 @ ("flat_map" | "filter_map" | "map"), [_, arg2], span2)) = method_call(recv) {
2344+
if let Some((name2 @ "map", [_, arg2], span2)) = method_call(recv) {
23452345
map_then_identity_transformer::check(cx, span2, name2, arg2, name, arg);
23462346
}
23472347
flat_map_identity::check(cx, expr, arg, span);
@@ -2353,7 +2353,7 @@ fn check_methods<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>, msrv: Optio
23532353
_ => {},
23542354
},
23552355
(name @ "fold", [init, acc]) => {
2356-
if let Some((name2 @ ("flat_map" | "filter_map" | "map"), [_, arg2], span2)) = method_call(recv) {
2356+
if let Some((name2 @ "map", [_, arg2], span2)) = method_call(recv) {
23572357
map_then_identity_transformer::check(cx, span2, name2, arg2, name, acc);
23582358
}
23592359
unnecessary_fold::check(cx, expr, init, acc, span);
@@ -2383,7 +2383,7 @@ fn check_methods<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>, msrv: Optio
23832383
filter_map::check(cx, expr, recv2, f_arg, span2, recv, m_arg, span, false);
23842384
},
23852385
("find", [f_arg]) => filter_map::check(cx, expr, recv2, f_arg, span2, recv, m_arg, span, true),
2386-
(name2 @ ("flat_map" | "filter_map" | "map"), [_, arg2]) => {
2386+
(name2 @ "map", [arg2]) => {
23872387
map_then_identity_transformer::check(cx, span2, name2, arg2, name, m_arg)
23882388
},
23892389
_ => {},

0 commit comments

Comments
 (0)