@@ -56,14 +56,14 @@ pub enum FnKind<'a> {
5656 Fn ( FnCtxt , Ident , & ' a FnSig , & ' a Visibility , & ' a Generics , Option < & ' a Block > ) ,
5757
5858 /// E.g., `|x, y| body`.
59- Closure ( & ' a FnDecl , & ' a Expr ) ,
59+ Closure ( & ' a ClosureBinder , & ' a FnDecl , & ' a Expr ) ,
6060}
6161
6262impl < ' a > FnKind < ' a > {
6363 pub fn header ( & self ) -> Option < & ' a FnHeader > {
6464 match * self {
6565 FnKind :: Fn ( _, _, sig, _, _, _) => Some ( & sig. header ) ,
66- FnKind :: Closure ( _, _) => None ,
66+ FnKind :: Closure ( _, _, _ ) => None ,
6767 }
6868 }
6969
@@ -77,7 +77,7 @@ impl<'a> FnKind<'a> {
7777 pub fn decl ( & self ) -> & ' a FnDecl {
7878 match self {
7979 FnKind :: Fn ( _, _, sig, _, _, _) => & sig. decl ,
80- FnKind :: Closure ( decl, _) => decl,
80+ FnKind :: Closure ( _ , decl, _) => decl,
8181 }
8282 }
8383
@@ -155,6 +155,9 @@ pub trait Visitor<'ast>: Sized {
155155 fn visit_generics ( & mut self , g : & ' ast Generics ) {
156156 walk_generics ( self , g)
157157 }
158+ fn visit_closure_binder ( & mut self , b : & ' ast ClosureBinder ) {
159+ walk_closure_binder ( self , b)
160+ }
158161 fn visit_where_predicate ( & mut self , p : & ' ast WherePredicate ) {
159162 walk_where_predicate ( self , p)
160163 }
@@ -636,6 +639,15 @@ pub fn walk_generics<'a, V: Visitor<'a>>(visitor: &mut V, generics: &'a Generics
636639 walk_list ! ( visitor, visit_where_predicate, & generics. where_clause. predicates) ;
637640}
638641
642+ pub fn walk_closure_binder < ' a , V : Visitor < ' a > > ( visitor : & mut V , binder : & ' a ClosureBinder ) {
643+ match binder {
644+ ClosureBinder :: NotPresent => { }
645+ ClosureBinder :: For { span : _, generic_params } => {
646+ walk_list ! ( visitor, visit_generic_param, generic_params)
647+ }
648+ }
649+ }
650+
639651pub fn walk_where_predicate < ' a , V : Visitor < ' a > > ( visitor : & mut V , predicate : & ' a WherePredicate ) {
640652 match * predicate {
641653 WherePredicate :: BoundPredicate ( WhereBoundPredicate {
@@ -682,7 +694,8 @@ pub fn walk_fn<'a, V: Visitor<'a>>(visitor: &mut V, kind: FnKind<'a>, _span: Spa
682694 walk_fn_decl ( visitor, & sig. decl ) ;
683695 walk_list ! ( visitor, visit_block, body) ;
684696 }
685- FnKind :: Closure ( decl, body) => {
697+ FnKind :: Closure ( binder, decl, body) => {
698+ visitor. visit_closure_binder ( binder) ;
686699 walk_fn_decl ( visitor, decl) ;
687700 visitor. visit_expr ( body) ;
688701 }
@@ -856,8 +869,8 @@ pub fn walk_expr<'a, V: Visitor<'a>>(visitor: &mut V, expression: &'a Expr) {
856869 visitor. visit_expr ( subexpression) ;
857870 walk_list ! ( visitor, visit_arm, arms) ;
858871 }
859- ExprKind :: Closure ( _, _, _, ref decl, ref body, _decl_span) => {
860- visitor. visit_fn ( FnKind :: Closure ( decl, body) , expression. span , expression. id )
872+ ExprKind :: Closure ( ref binder , _, _, _, ref decl, ref body, _decl_span) => {
873+ visitor. visit_fn ( FnKind :: Closure ( binder , decl, body) , expression. span , expression. id )
861874 }
862875 ExprKind :: Block ( ref block, ref opt_label) => {
863876 walk_list ! ( visitor, visit_label, opt_label) ;
0 commit comments