@@ -543,6 +543,10 @@ impl<'a, 'b> Context<'a, 'b> {
543543 let mut pats = Vec :: new ( ) ;
544544 let mut heads = Vec :: new ( ) ;
545545
546+ let names_pos: Vec < _ > = ( 0 ..self . args . len ( ) ) . map ( |i| {
547+ self . ecx . ident_of ( & format ! ( "arg{}" , i) ) . gensym ( )
548+ } ) . collect ( ) ;
549+
546550 // First, build up the static array which will become our precompiled
547551 // format "string"
548552 let pieces = self . ecx . expr_vec_slice ( self . fmtsp , self . str_pieces ) ;
@@ -560,7 +564,7 @@ impl<'a, 'b> Context<'a, 'b> {
560564 // of each variable because we don't want to move out of the arguments
561565 // passed to this function.
562566 for ( i, e) in self . args . into_iter ( ) . enumerate ( ) {
563- let name = self . ecx . ident_of ( & format ! ( "__arg{}" , i ) ) ;
567+ let name = names_pos [ i ] ;
564568 let span =
565569 DUMMY_SP . with_ctxt ( e. span . ctxt ( ) . apply_mark ( self . ecx . current_expansion . mark ) ) ;
566570 pats. push ( self . ecx . pat_ident ( span, name) ) ;
@@ -570,14 +574,12 @@ impl<'a, 'b> Context<'a, 'b> {
570574 heads. push ( self . ecx . expr_addr_of ( e. span , e) ) ;
571575 }
572576 for pos in self . count_args {
573- let name = self . ecx . ident_of ( & match pos {
574- Exact ( i) => format ! ( "__arg{}" , i) ,
575- _ => panic ! ( "should never happen" ) ,
576- } ) ;
577- let span = match pos {
578- Exact ( i) => spans_pos[ i] ,
577+ let index = match pos {
578+ Exact ( i) => i,
579579 _ => panic ! ( "should never happen" ) ,
580580 } ;
581+ let name = names_pos[ index] ;
582+ let span = spans_pos[ index] ;
581583 counts. push ( Context :: format_arg ( self . ecx , self . macsp , span, & Count , name) ) ;
582584 }
583585
0 commit comments