@@ -28,7 +28,7 @@ use rustc::util::common::ErrorReported;
2828
2929use rustc:: hir:: def:: * ;
3030use rustc:: hir:: def_id:: DefId ;
31- use rustc:: hir:: intravisit:: { self , Visitor , FnKind , NestedVisitorMap } ;
31+ use rustc:: hir:: intravisit:: { self , Visitor , NestedVisitorMap } ;
3232use rustc:: hir:: { self , Pat , PatKind } ;
3333
3434use rustc_back:: slice;
@@ -44,47 +44,11 @@ impl<'a, 'tcx> Visitor<'tcx> for OuterVisitor<'a, 'tcx> {
4444 NestedVisitorMap :: OnlyBodies ( & self . tcx . hir )
4545 }
4646
47- fn visit_fn ( & mut self , fk : FnKind < ' tcx > , fd : & ' tcx hir:: FnDecl ,
48- b : hir:: BodyId , s : Span , id : ast:: NodeId ) {
49- intravisit:: walk_fn ( self , fk, fd, b, s, id) ;
50-
51- check_body ( self . tcx , b) ;
52- }
53-
54- fn visit_item ( & mut self , item : & ' tcx hir:: Item ) {
55- intravisit:: walk_item ( self , item) ;
56- match item. node {
57- hir:: ItemStatic ( .., body_id) | hir:: ItemConst ( .., body_id) => {
58- check_body ( self . tcx , body_id) ;
59- }
60- _ => ( ) ,
61- }
62- }
63-
64- fn visit_impl_item ( & mut self , ii : & ' tcx hir:: ImplItem ) {
65- intravisit:: walk_impl_item ( self , ii) ;
66- if let hir:: ImplItemKind :: Const ( _, body_id) = ii. node {
67- check_body ( self . tcx , body_id) ;
68- }
69- }
70-
71- fn visit_trait_item ( & mut self , ti : & ' tcx hir:: TraitItem ) {
72- intravisit:: walk_trait_item ( self , ti) ;
73- if let hir:: TraitItemKind :: Const ( _, Some ( body_id) ) = ti. node {
74- check_body ( self . tcx , body_id) ;
75- }
47+ fn visit_body ( & mut self , body : & ' tcx hir:: Body ) {
48+ intravisit:: walk_body ( self , body) ;
49+ let def_id = self . tcx . hir . body_owner_def_id ( body. id ( ) ) ;
50+ let _ = self . tcx . check_match ( def_id) ;
7651 }
77-
78- // Enum variants and types (e.g. `[T; { .. }]`) may have bodies too,
79- // but they are const-evaluated during typeck.
80- }
81-
82- fn check_body < ' a , ' tcx > (
83- tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
84- body_id : hir:: BodyId ,
85- ) {
86- let def_id = tcx. hir . body_owner_def_id ( body_id) ;
87- let _ = tcx. check_match ( def_id) ;
8852}
8953
9054pub fn check_crate < ' a , ' tcx > ( tcx : TyCtxt < ' a , ' tcx , ' tcx > ) {
0 commit comments