Skip to content

Commit 37555f8

Browse files
committed
Use path_to_local_id
1 parent 5db48a3 commit 37555f8

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

clippy_lints/src/methods/filter_map_identity.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::utils::{match_qpath, match_trait_method, paths, span_lint_and_sugg};
1+
use crate::utils::{match_qpath, match_trait_method, path_to_local_id, paths, span_lint_and_sugg};
22
use if_chain::if_chain;
33
use rustc_errors::Applicability;
44
use rustc_hir as hir;
@@ -32,12 +32,8 @@ pub(super) fn check(
3232
if let hir::ExprKind::Closure(_, _, body_id, _, _) = arg_node;
3333
let body = cx.tcx.hir().body(*body_id);
3434

35-
if let hir::PatKind::Binding(_, _, binding_ident, _) = body.params[0].pat.kind;
36-
if let hir::ExprKind::Path(hir::QPath::Resolved(_, ref path)) = body.value.kind;
37-
38-
if path.segments.len() == 1;
39-
if path.segments[0].ident.name == binding_ident.name;
40-
35+
if let hir::PatKind::Binding(_, binding_id, ..) = body.params[0].pat.kind;
36+
if path_to_local_id(&body.value, binding_id);
4137
then {
4238
apply_lint("called `filter_map(|x| x)` on an `Iterator`");
4339
}

0 commit comments

Comments
 (0)