@@ -21,29 +21,23 @@ use rustc_span::Span;
21
21
use syntax:: ast:: Attribute ;
22
22
use syntax:: attr;
23
23
24
- pub ( crate ) trait TargetExt {
25
- fn from_impl_item < ' tcx > ( tcx : TyCtxt < ' tcx > , impl_item : & hir:: ImplItem < ' _ > ) -> Target ;
26
- }
27
-
28
- impl TargetExt for Target {
29
- fn from_impl_item < ' tcx > ( tcx : TyCtxt < ' tcx > , impl_item : & hir:: ImplItem < ' _ > ) -> Target {
30
- match impl_item. kind {
31
- hir:: ImplItemKind :: Const ( ..) => Target :: AssocConst ,
32
- hir:: ImplItemKind :: Method ( ..) => {
33
- let parent_hir_id = tcx. hir ( ) . get_parent_item ( impl_item. hir_id ) ;
34
- let containing_item = tcx. hir ( ) . expect_item ( parent_hir_id) ;
35
- let containing_impl_is_for_trait = match & containing_item. kind {
36
- hir:: ItemKind :: Impl { ref of_trait, .. } => of_trait. is_some ( ) ,
37
- _ => bug ! ( "parent of an ImplItem must be an Impl" ) ,
38
- } ;
39
- if containing_impl_is_for_trait {
40
- Target :: Method ( MethodKind :: Trait { body : true } )
41
- } else {
42
- Target :: Method ( MethodKind :: Inherent )
43
- }
24
+ fn target_from_impl_item < ' tcx > ( tcx : TyCtxt < ' tcx > , impl_item : & hir:: ImplItem < ' _ > ) -> Target {
25
+ match impl_item. kind {
26
+ hir:: ImplItemKind :: Const ( ..) => Target :: AssocConst ,
27
+ hir:: ImplItemKind :: Method ( ..) => {
28
+ let parent_hir_id = tcx. hir ( ) . get_parent_item ( impl_item. hir_id ) ;
29
+ let containing_item = tcx. hir ( ) . expect_item ( parent_hir_id) ;
30
+ let containing_impl_is_for_trait = match & containing_item. kind {
31
+ hir:: ItemKind :: Impl { ref of_trait, .. } => of_trait. is_some ( ) ,
32
+ _ => bug ! ( "parent of an ImplItem must be an Impl" ) ,
33
+ } ;
34
+ if containing_impl_is_for_trait {
35
+ Target :: Method ( MethodKind :: Trait { body : true } )
36
+ } else {
37
+ Target :: Method ( MethodKind :: Inherent )
44
38
}
45
- hir:: ImplItemKind :: TyAlias ( ..) | hir:: ImplItemKind :: OpaqueTy ( ..) => Target :: AssocTy ,
46
39
}
40
+ hir:: ImplItemKind :: TyAlias ( ..) | hir:: ImplItemKind :: OpaqueTy ( ..) => Target :: AssocTy ,
47
41
}
48
42
}
49
43
@@ -437,7 +431,7 @@ impl Visitor<'tcx> for CheckAttrVisitor<'tcx> {
437
431
}
438
432
439
433
fn visit_impl_item ( & mut self , impl_item : & ' tcx hir:: ImplItem < ' tcx > ) {
440
- let target = Target :: from_impl_item ( self . tcx , impl_item) ;
434
+ let target = target_from_impl_item ( self . tcx , impl_item) ;
441
435
self . check_attributes ( impl_item. hir_id , & impl_item. attrs , & impl_item. span , target, None ) ;
442
436
intravisit:: walk_impl_item ( self , impl_item)
443
437
}
0 commit comments