@@ -391,6 +391,30 @@ macro_rules! make_ast_visitor {
391391 return_result!( V )
392392 }
393393
394+ pub fn walk_format_args<$( $lt, ) ? V : $trait$( <$lt>) ?>(
395+ vis: & mut V ,
396+ fmt: ref_t!( FormatArgs )
397+ ) -> result!( V ) {
398+ // FIXME: visit the template exhaustively.
399+ let FormatArgs { span, template: _, arguments } = fmt;
400+ let arg_iter = macro_if!{ $( $mut) ? {
401+ arguments. all_args_mut( )
402+ } else {
403+ arguments. all_args( )
404+ } } ;
405+ for FormatArgument { kind, expr } in arg_iter {
406+ match kind {
407+ FormatArgumentKind :: Named ( ident) | FormatArgumentKind :: Captured ( ident) => {
408+ try_v!( vis. visit_ident( ident) ) ;
409+ }
410+ FormatArgumentKind :: Normal => { }
411+ }
412+ try_v!( vis. visit_expr( expr) ) ;
413+ }
414+ try_v!( visit_span!( vis, span) ) ;
415+ return_result!( V )
416+ }
417+
394418 pub fn walk_generic_args<$( $lt, ) ? V : $trait$( <$lt>) ?>(
395419 vis: & mut V ,
396420 generic_args: ref_t!( GenericArgs )
@@ -1257,20 +1281,6 @@ pub mod visit {
12571281 visitor. visit_path ( path, * id)
12581282 }
12591283
1260- pub fn walk_format_args < ' a , V : Visitor < ' a > > ( visitor : & mut V , fmt : & ' a FormatArgs ) -> V :: Result {
1261- let FormatArgs { span : _, template : _, arguments } = fmt;
1262- for FormatArgument { kind, expr } in arguments. all_args ( ) {
1263- match kind {
1264- FormatArgumentKind :: Named ( ident) | FormatArgumentKind :: Captured ( ident) => {
1265- try_visit ! ( visitor. visit_ident( ident) )
1266- }
1267- FormatArgumentKind :: Normal => { }
1268- }
1269- try_visit ! ( visitor. visit_expr( expr) ) ;
1270- }
1271- V :: Result :: output ( )
1272- }
1273-
12741284 pub fn walk_expr < ' a , V : Visitor < ' a > > ( visitor : & mut V , expression : & ' a Expr ) -> V :: Result {
12751285 let Expr { id, kind, span, attrs, tokens : _ } = expression;
12761286 walk_list ! ( visitor, visit_attribute, attrs) ;
@@ -2597,21 +2607,6 @@ pub mod mut_visit {
25972607 vis. visit_path ( path) ;
25982608 }
25992609
2600- fn walk_format_args < T : MutVisitor > ( vis : & mut T , fmt : & mut FormatArgs ) {
2601- // FIXME: visit the template exhaustively.
2602- let FormatArgs { span, template : _, arguments } = fmt;
2603- for FormatArgument { kind, expr } in arguments. all_args_mut ( ) {
2604- match kind {
2605- FormatArgumentKind :: Named ( ident) | FormatArgumentKind :: Captured ( ident) => {
2606- vis. visit_ident ( ident)
2607- }
2608- FormatArgumentKind :: Normal => { }
2609- }
2610- vis. visit_expr ( expr) ;
2611- }
2612- vis. visit_span ( span) ;
2613- }
2614-
26152610 pub fn walk_expr < T : MutVisitor > (
26162611 vis : & mut T ,
26172612 Expr { kind, id, span, attrs, tokens } : & mut Expr ,
0 commit comments