@@ -99,7 +99,7 @@ declare_clippy_lint! {
9999
100100#[ derive( Default ) ]
101101pub ( crate ) struct Shadow {
102- bindings : Vec < FxHashMap < Symbol , Vec < ItemLocalId > > > ,
102+ bindings : Vec < ( FxHashMap < Symbol , Vec < ItemLocalId > > , LocalDefId ) > ,
103103}
104104
105105impl_lint_pass ! ( Shadow => [ SHADOW_SAME , SHADOW_REUSE , SHADOW_UNRELATED ] ) ;
@@ -121,7 +121,7 @@ impl<'tcx> LateLintPass<'tcx> for Shadow {
121121
122122 let HirId { owner, local_id } = id;
123123 // get (or insert) the list of items for this owner and symbol
124- let data = self . bindings . last_mut ( ) . unwrap ( ) ;
124+ let ( ref mut data, scope_owner ) = * self . bindings . last_mut ( ) . unwrap ( ) ;
125125 let items_with_name = data. entry ( ident. name ) . or_default ( ) ;
126126
127127 // check other bindings with the same name, most recently seen first
@@ -131,7 +131,7 @@ impl<'tcx> LateLintPass<'tcx> for Shadow {
131131 return ;
132132 }
133133
134- if is_shadow ( cx, owner , prev, local_id) {
134+ if is_shadow ( cx, scope_owner , prev, local_id) {
135135 let prev_hir_id = HirId { owner, local_id : prev } ;
136136 lint_shadow ( cx, pat, prev_hir_id, ident. span ) ;
137137 // only lint against the "nearest" shadowed binding
@@ -144,11 +144,9 @@ impl<'tcx> LateLintPass<'tcx> for Shadow {
144144
145145 fn check_body ( & mut self , cx : & LateContext < ' _ > , body : & Body < ' _ > ) {
146146 let hir = cx. tcx . hir ( ) ;
147- if !matches ! (
148- hir. body_owner_kind( hir. body_owner_def_id( body. id( ) ) ) ,
149- BodyOwnerKind :: Closure
150- ) {
151- self . bindings . push ( FxHashMap :: default ( ) ) ;
147+ let owner_id = hir. body_owner_def_id ( body. id ( ) ) ;
148+ if !matches ! ( hir. body_owner_kind( owner_id) , BodyOwnerKind :: Closure ) {
149+ self . bindings . push ( ( FxHashMap :: default ( ) , owner_id) ) ;
152150 }
153151 }
154152
0 commit comments