@@ -570,16 +570,43 @@ impl<'a, 'tcx> Visitor<'tcx> for CheckItemTypesVisitor<'a, 'tcx> {
570
570
}
571
571
572
572
impl < ' a , ' tcx > ItemLikeVisitor < ' tcx > for CheckItemBodiesVisitor < ' a , ' tcx > {
573
- fn visit_item ( & mut self , i : & ' tcx hir:: Item ) {
574
- check_item_body ( self . ccx , i) ;
573
+ fn visit_item ( & mut self , item : & ' tcx hir:: Item ) {
574
+ match item. node {
575
+ hir:: ItemFn ( ref decl, .., body_id) => {
576
+ check_bare_fn ( self . ccx , & decl, body_id, item. id , item. span ) ;
577
+ }
578
+ _ => { }
579
+ }
575
580
}
576
581
577
- fn visit_trait_item ( & mut self , _item : & ' tcx hir:: TraitItem ) {
578
- // done as part of `visit_item` above
582
+ fn visit_trait_item ( & mut self , trait_item : & ' tcx hir:: TraitItem ) {
583
+ match trait_item. node {
584
+ hir:: TraitItemKind :: Const ( _, Some ( expr) ) => {
585
+ check_const ( self . ccx , expr, trait_item. id )
586
+ }
587
+ hir:: TraitItemKind :: Method ( ref sig, hir:: TraitMethod :: Provided ( body_id) ) => {
588
+ check_bare_fn ( self . ccx , & sig. decl , body_id, trait_item. id , trait_item. span ) ;
589
+ }
590
+ hir:: TraitItemKind :: Method ( _, hir:: TraitMethod :: Required ( _) ) |
591
+ hir:: TraitItemKind :: Const ( _, None ) |
592
+ hir:: TraitItemKind :: Type ( ..) => {
593
+ // Nothing to do.
594
+ }
595
+ }
579
596
}
580
597
581
- fn visit_impl_item ( & mut self , _item : & ' tcx hir:: ImplItem ) {
582
- // done as part of `visit_item` above
598
+ fn visit_impl_item ( & mut self , impl_item : & ' tcx hir:: ImplItem ) {
599
+ match impl_item. node {
600
+ hir:: ImplItemKind :: Const ( _, expr) => {
601
+ check_const ( self . ccx , expr, impl_item. id )
602
+ }
603
+ hir:: ImplItemKind :: Method ( ref sig, body_id) => {
604
+ check_bare_fn ( self . ccx , & sig. decl , body_id, impl_item. id , impl_item. span ) ;
605
+ }
606
+ hir:: ImplItemKind :: Type ( _) => {
607
+ // Nothing to do here.
608
+ }
609
+ }
583
610
}
584
611
}
585
612
@@ -897,55 +924,6 @@ pub fn check_item_type<'a,'tcx>(ccx: &CrateCtxt<'a,'tcx>, it: &'tcx hir::Item) {
897
924
}
898
925
}
899
926
900
- pub fn check_item_body < ' a , ' tcx > ( ccx : & CrateCtxt < ' a , ' tcx > , it : & ' tcx hir:: Item ) {
901
- debug ! ( "check_item_body(it.id={}, it.name={})" ,
902
- it. id,
903
- ccx. tcx. item_path_str( ccx. tcx. map. local_def_id( it. id) ) ) ;
904
- let _indenter = indenter ( ) ;
905
- match it. node {
906
- hir:: ItemFn ( ref decl, .., body_id) => {
907
- check_bare_fn ( ccx, & decl, body_id, it. id , it. span ) ;
908
- }
909
- hir:: ItemImpl ( .., ref impl_item_refs) => {
910
- debug ! ( "ItemImpl {} with id {}" , it. name, it. id) ;
911
-
912
- for impl_item_ref in impl_item_refs {
913
- let impl_item = ccx. tcx . map . impl_item ( impl_item_ref. id ) ;
914
- match impl_item. node {
915
- hir:: ImplItemKind :: Const ( _, expr) => {
916
- check_const ( ccx, expr, impl_item. id )
917
- }
918
- hir:: ImplItemKind :: Method ( ref sig, body_id) => {
919
- check_bare_fn ( ccx, & sig. decl , body_id, impl_item. id , impl_item. span ) ;
920
- }
921
- hir:: ImplItemKind :: Type ( _) => {
922
- // Nothing to do here.
923
- }
924
- }
925
- }
926
- }
927
- hir:: ItemTrait ( .., ref trait_item_refs) => {
928
- for trait_item_ref in trait_item_refs {
929
- let trait_item = ccx. tcx . map . trait_item ( trait_item_ref. id ) ;
930
- match trait_item. node {
931
- hir:: TraitItemKind :: Const ( _, Some ( expr) ) => {
932
- check_const ( ccx, expr, trait_item. id )
933
- }
934
- hir:: TraitItemKind :: Method ( ref sig, hir:: TraitMethod :: Provided ( body_id) ) => {
935
- check_bare_fn ( ccx, & sig. decl , body_id, trait_item. id , trait_item. span ) ;
936
- }
937
- hir:: TraitItemKind :: Method ( _, hir:: TraitMethod :: Required ( _) ) |
938
- hir:: TraitItemKind :: Const ( _, None ) |
939
- hir:: TraitItemKind :: Type ( ..) => {
940
- // Nothing to do.
941
- }
942
- }
943
- }
944
- }
945
- _ => { /* nothing to do */ }
946
- }
947
- }
948
-
949
927
fn check_on_unimplemented < ' a , ' tcx > ( ccx : & CrateCtxt < ' a , ' tcx > ,
950
928
def_id : DefId ,
951
929
item : & hir:: Item ) {
0 commit comments