@@ -128,6 +128,11 @@ impl<'tcx> LateLintPass<'tcx> for UseSelf {
128128 }
129129
130130 fn check_impl_item ( & mut self , cx : & LateContext < ' _ > , impl_item : & hir:: ImplItem < ' _ > ) {
131+ // Checking items of `impl Self` blocks in which macro expands into.
132+ if impl_item. span . from_expansion ( ) {
133+ self . stack . push ( StackItem :: NoCheck ) ;
134+ return ;
135+ }
131136 // We want to skip types in trait `impl`s that aren't declared as `Self` in the trait
132137 // declaration. The collection of those types is all this method implementation does.
133138 if let ImplItemKind :: Fn ( FnSig { decl, .. } , ..) = impl_item. kind
@@ -183,6 +188,13 @@ impl<'tcx> LateLintPass<'tcx> for UseSelf {
183188 }
184189 }
185190
191+ fn check_impl_item_post ( & mut self , _: & LateContext < ' _ > , impl_item : & hir:: ImplItem < ' _ > ) {
192+ if impl_item. span . from_expansion ( )
193+ && let Some ( StackItem :: NoCheck ) = self . stack . last ( )
194+ {
195+ self . stack . pop ( ) ;
196+ }
197+ }
186198
187199 fn check_ty ( & mut self , cx : & LateContext < ' tcx > , hir_ty : & Ty < ' tcx , AmbigArg > ) {
188200 if !hir_ty. span . from_expansion ( )
@@ -197,7 +209,7 @@ impl<'tcx> LateLintPass<'tcx> for UseSelf {
197209 Res :: SelfTyParam { .. } | Res :: SelfTyAlias { .. } | Res :: Def ( DefKind :: TyParam , _)
198210 )
199211 && !types_to_skip. contains ( & hir_ty. hir_id )
200- && let ty = ty_from_hir_ty ( cx, hir_ty)
212+ && let ty = ty_from_hir_ty ( cx, hir_ty. as_unambig_ty ( ) )
201213 && let impl_ty = cx. tcx . type_of ( impl_id) . instantiate_identity ( )
202214 && same_type_and_consts ( ty, impl_ty)
203215 // Ensure the type we encounter and the one from the impl have the same lifetime parameters. It may be that
0 commit comments