@@ -2,6 +2,7 @@ use clippy_utils::diagnostics::span_lint_and_sugg;
2
2
use clippy_utils:: ty:: same_type_and_consts;
3
3
use clippy_utils:: { in_macro, meets_msrv, msrvs} ;
4
4
use if_chain:: if_chain;
5
+ use rustc_data_structures:: fx:: FxHashSet ;
5
6
use rustc_errors:: Applicability ;
6
7
use rustc_hir:: {
7
8
self as hir,
@@ -75,7 +76,7 @@ enum StackItem {
75
76
Check {
76
77
hir_id : HirId ,
77
78
impl_trait_ref_def_id : Option < LocalDefId > ,
78
- types_to_skip : Vec < HirId > ,
79
+ types_to_skip : FxHashSet < HirId > ,
79
80
types_to_lint : Vec < HirId > ,
80
81
} ,
81
82
NoCheck ,
@@ -111,7 +112,7 @@ impl<'tcx> LateLintPass<'tcx> for UseSelf {
111
112
hir_id: self_ty. hir_id,
112
113
impl_trait_ref_def_id,
113
114
types_to_lint: Vec :: new( ) ,
114
- types_to_skip: Vec :: new ( ) ,
115
+ types_to_skip: std :: iter :: once ( self_ty . hir_id ) . collect ( ) ,
115
116
}
116
117
} else {
117
118
StackItem :: NoCheck
@@ -216,7 +217,7 @@ impl<'tcx> LateLintPass<'tcx> for UseSelf {
216
217
217
218
fn check_ty ( & mut self , cx : & LateContext < ' _ > , hir_ty : & hir:: Ty < ' _ > ) {
218
219
if_chain ! {
219
- if !in_macro( hir_ty. span) && !in_impl ( cx , hir_ty ) ;
220
+ if !in_macro( hir_ty. span) ;
220
221
if meets_msrv( self . msrv. as_ref( ) , & msrvs:: TYPE_ALIAS_ENUM_VARIANTS ) ;
221
222
if let Some ( StackItem :: Check {
222
223
hir_id,
@@ -358,20 +359,6 @@ fn ty_from_hir_id<'tcx>(cx: &LateContext<'tcx>, hir_id: HirId) -> Ty<'tcx> {
358
359
}
359
360
}
360
361
361
- fn in_impl ( cx : & LateContext < ' tcx > , hir_ty : & hir:: Ty < ' _ > ) -> bool {
362
- let map = cx. tcx . hir ( ) ;
363
- let parent = map. get_parent_node ( hir_ty. hir_id ) ;
364
- if_chain ! {
365
- if let Some ( Node :: Item ( item) ) = map. find( parent) ;
366
- if let ItemKind :: Impl { .. } = item. kind;
367
- then {
368
- true
369
- } else {
370
- false
371
- }
372
- }
373
- }
374
-
375
362
fn should_lint_ty ( hir_ty : & hir:: Ty < ' _ > , ty : Ty < ' _ > , self_ty : Ty < ' _ > ) -> bool {
376
363
if_chain ! {
377
364
if same_type_and_consts( ty, self_ty) ;
0 commit comments