@@ -11,7 +11,6 @@ use rustc_lint::{EarlyContext, EarlyLintPass, LateContext, LateLintPass, LintCon
1111use rustc_middle:: hir:: map:: Map ;
1212use rustc_middle:: lint:: in_external_macro;
1313use rustc_session:: { declare_lint_pass, declare_tool_lint} ;
14- use rustc_span:: symbol:: Ident ;
1514
1615declare_clippy_lint ! {
1716 /// **What it does:** Detects closures called in the same expression where they
@@ -96,9 +95,9 @@ impl EarlyLintPass for RedundantClosureCall {
9695
9796impl < ' tcx > LateLintPass < ' tcx > for RedundantClosureCall {
9897 fn check_block ( & mut self , cx : & LateContext < ' tcx > , block : & ' tcx hir:: Block < ' _ > ) {
99- fn count_closure_usage < ' tcx > ( block : & ' tcx hir:: Block < ' _ > , ident : & ' tcx Ident ) -> usize {
98+ fn count_closure_usage < ' tcx > ( block : & ' tcx hir:: Block < ' _ > , path : & ' tcx hir :: Path < ' tcx > ) -> usize {
10099 struct ClosureUsageCount < ' tcx > {
101- ident : & ' tcx Ident ,
100+ path : & ' tcx hir :: Path < ' tcx > ,
102101 count : usize ,
103102 } ;
104103 impl < ' tcx > hir_visit:: Visitor < ' tcx > for ClosureUsageCount < ' tcx > {
@@ -108,7 +107,8 @@ impl<'tcx> LateLintPass<'tcx> for RedundantClosureCall {
108107 if_chain ! {
109108 if let hir:: ExprKind :: Call ( ref closure, _) = expr. kind;
110109 if let hir:: ExprKind :: Path ( hir:: QPath :: Resolved ( _, ref path) ) = closure. kind;
111- if self . ident == & path. segments[ 0 ] . ident;
110+ if self . path. segments[ 0 ] . ident == path. segments[ 0 ] . ident
111+ && self . path. res == path. res;
112112 then {
113113 self . count += 1 ;
114114 }
@@ -120,7 +120,7 @@ impl<'tcx> LateLintPass<'tcx> for RedundantClosureCall {
120120 hir_visit:: NestedVisitorMap :: None
121121 }
122122 } ;
123- let mut closure_usage_count = ClosureUsageCount { ident , count : 0 } ;
123+ let mut closure_usage_count = ClosureUsageCount { path , count : 0 } ;
124124 closure_usage_count. visit_block ( block) ;
125125 closure_usage_count. count
126126 }
@@ -136,7 +136,7 @@ impl<'tcx> LateLintPass<'tcx> for RedundantClosureCall {
136136 if let hir:: ExprKind :: Call ( ref closure, _) = call. kind;
137137 if let hir:: ExprKind :: Path ( hir:: QPath :: Resolved ( _, ref path) ) = closure. kind;
138138 if ident == path. segments[ 0 ] . ident;
139- if count_closure_usage( block, & ident ) == 1 ;
139+ if count_closure_usage( block, path ) == 1 ;
140140 then {
141141 span_lint(
142142 cx,
0 commit comments