@@ -128,6 +128,11 @@ impl<'tcx> LateLintPass<'tcx> for UseSelf {
128
128
}
129
129
130
130
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
+ }
131
136
// We want to skip types in trait `impl`s that aren't declared as `Self` in the trait
132
137
// declaration. The collection of those types is all this method implementation does.
133
138
if let ImplItemKind :: Fn ( FnSig { decl, .. } , ..) = impl_item. kind
@@ -183,6 +188,13 @@ impl<'tcx> LateLintPass<'tcx> for UseSelf {
183
188
}
184
189
}
185
190
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
+ }
186
198
187
199
fn check_ty ( & mut self , cx : & LateContext < ' tcx > , hir_ty : & Ty < ' tcx , AmbigArg > ) {
188
200
if !hir_ty. span . from_expansion ( )
@@ -197,7 +209,7 @@ impl<'tcx> LateLintPass<'tcx> for UseSelf {
197
209
Res :: SelfTyParam { .. } | Res :: SelfTyAlias { .. } | Res :: Def ( DefKind :: TyParam , _)
198
210
)
199
211
&& !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 ( ) )
201
213
&& let impl_ty = cx. tcx . type_of ( impl_id) . instantiate_identity ( )
202
214
&& same_type_and_consts ( ty, impl_ty)
203
215
// Ensure the type we encounter and the one from the impl have the same lifetime parameters. It may be that
0 commit comments