@@ -57,6 +57,11 @@ impl<'a> FnKind<'a> {
5757 }
5858}
5959
60+ pub enum BodyHeader < ' a > {
61+ Fn ( FnKind < ' a > , & ' a FnDecl ) ,
62+ Constant
63+ }
64+
6065/// Each method of the Visitor trait is a hook to be potentially
6166/// overridden. Each method's default implementation recursively visits
6267/// the substructure of the input via the corresponding `walk` method;
@@ -145,6 +150,9 @@ pub trait Visitor<'v> : Sized {
145150 fn visit_fn ( & mut self , fk : FnKind < ' v > , fd : & ' v FnDecl , b : & ' v Expr , s : Span , id : NodeId ) {
146151 walk_fn ( self , fk, fd, b, s, id)
147152 }
153+ fn visit_body ( & mut self , _header : BodyHeader < ' v > , body : & ' v Expr , _s : Span , _id : NodeId ) {
154+ self . visit_expr ( body) ;
155+ }
148156 fn visit_trait_item ( & mut self , ti : & ' v TraitItem ) {
149157 walk_trait_item ( self , ti)
150158 }
@@ -651,12 +659,13 @@ pub fn walk_fn<'v, V: Visitor<'v>>(visitor: &mut V,
651659 function_kind : FnKind < ' v > ,
652660 function_declaration : & ' v FnDecl ,
653661 function_body : & ' v Expr ,
654- _span : Span ,
662+ span : Span ,
655663 id : NodeId ) {
656664 visitor. visit_id ( id) ;
657- walk_fn_decl ( visitor, function_declaration) ;
658665 walk_fn_kind ( visitor, function_kind) ;
659- visitor. visit_expr ( function_body)
666+ walk_fn_decl ( visitor, function_declaration) ;
667+ visitor. visit_body ( BodyHeader :: Fn ( function_kind, function_declaration) ,
668+ function_body, span, id) ;
660669}
661670
662671pub fn walk_trait_item < ' v , V : Visitor < ' v > > ( visitor : & mut V , trait_item : & ' v TraitItem ) {
0 commit comments