@@ -396,7 +396,8 @@ macro_rules! make_ast_visitor {
396
396
$vis. visit_ident( $ident)
397
397
,
398
398
$vis. visit_ident( * $ident)
399
- ) }
399
+ )
400
+ }
400
401
}
401
402
402
403
macro_rules! return_result {
@@ -416,6 +417,18 @@ macro_rules! make_ast_visitor {
416
417
}
417
418
}
418
419
420
+ macro_rules! visit_list {
421
+ ( $visitor: expr, $visit: ident, $flat_map: ident, $list: expr) => {
422
+ if_mut_expr!(
423
+ $list. flat_map_in_place( |x| $visitor. $flat_map( x) )
424
+ ,
425
+ for elem in $list {
426
+ try_v!( $visitor. $visit( elem) ) ;
427
+ }
428
+ )
429
+ }
430
+ }
431
+
419
432
pub fn walk_ident<$( $lt, ) ? V : $trait$( <$lt>) ?>(
420
433
vis: & mut V ,
421
434
ident: if_mut_ty!( ref_t!( Ident ) , Ident )
@@ -527,6 +540,20 @@ macro_rules! make_ast_visitor {
527
540
return_result!( V )
528
541
}
529
542
543
+ pub fn walk_closure_binder<$( $lt, ) ? V : $trait$( <$lt>) ?>(
544
+ vis: & mut V ,
545
+ binder: ref_t!( ClosureBinder )
546
+ ) -> result!( V ) {
547
+ match binder {
548
+ ClosureBinder :: NotPresent => { }
549
+ // TODO: skipped span
550
+ ClosureBinder :: For { generic_params, span: _ } => {
551
+ visit_list!( vis, visit_generic_param, flat_map_generic_param, generic_params)
552
+ }
553
+ }
554
+ return_result!( V )
555
+ }
556
+
530
557
make_walk_flat_map!{ Arm , walk_flat_map_arm, visit_arm}
531
558
make_walk_flat_map!{ ExprField , walk_flat_map_expr_field, visit_expr_field}
532
559
make_walk_flat_map!{ FieldDef , walk_flat_map_field_def, visit_field_def}
@@ -1117,19 +1144,6 @@ pub mod visit {
1117
1144
V :: Result :: output ( )
1118
1145
}
1119
1146
1120
- pub fn walk_closure_binder < ' a , V : Visitor < ' a > > (
1121
- visitor : & mut V ,
1122
- binder : & ' a ClosureBinder ,
1123
- ) -> V :: Result {
1124
- match binder {
1125
- ClosureBinder :: NotPresent => { }
1126
- ClosureBinder :: For { generic_params, span : _ } => {
1127
- walk_list ! ( visitor, visit_generic_param, generic_params)
1128
- }
1129
- }
1130
- V :: Result :: output ( )
1131
- }
1132
-
1133
1147
pub fn walk_where_predicate < ' a , V : Visitor < ' a > > (
1134
1148
visitor : & mut V ,
1135
1149
predicate : & ' a WherePredicate ,
@@ -2144,15 +2158,6 @@ pub mod mut_visit {
2144
2158
}
2145
2159
}
2146
2160
2147
- fn walk_closure_binder < T : MutVisitor > ( vis : & mut T , binder : & mut ClosureBinder ) {
2148
- match binder {
2149
- ClosureBinder :: NotPresent => { }
2150
- ClosureBinder :: For { span : _, generic_params } => {
2151
- generic_params. flat_map_in_place ( |param| vis. flat_map_generic_param ( param) ) ;
2152
- }
2153
- }
2154
- }
2155
-
2156
2161
fn walk_coroutine_kind < T : MutVisitor > ( vis : & mut T , coroutine_kind : & mut CoroutineKind ) {
2157
2162
match coroutine_kind {
2158
2163
CoroutineKind :: Async { span, closure_id, return_impl_trait_id }
0 commit comments