@@ -543,6 +543,10 @@ impl<'a, 'b> Context<'a, 'b> {
543
543
let mut pats = Vec :: new ( ) ;
544
544
let mut heads = Vec :: new ( ) ;
545
545
546
+ let names_pos: Vec < _ > = ( 0 ..self . args . len ( ) ) . map ( |i| {
547
+ self . ecx . ident_of ( & format ! ( "arg{}" , i) ) . gensym ( )
548
+ } ) . collect ( ) ;
549
+
546
550
// First, build up the static array which will become our precompiled
547
551
// format "string"
548
552
let pieces = self . ecx . expr_vec_slice ( self . fmtsp , self . str_pieces ) ;
@@ -560,7 +564,7 @@ impl<'a, 'b> Context<'a, 'b> {
560
564
// of each variable because we don't want to move out of the arguments
561
565
// passed to this function.
562
566
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 ] ;
564
568
let span =
565
569
DUMMY_SP . with_ctxt ( e. span . ctxt ( ) . apply_mark ( self . ecx . current_expansion . mark ) ) ;
566
570
pats. push ( self . ecx . pat_ident ( span, name) ) ;
@@ -570,14 +574,12 @@ impl<'a, 'b> Context<'a, 'b> {
570
574
heads. push ( self . ecx . expr_addr_of ( e. span , e) ) ;
571
575
}
572
576
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,
579
579
_ => panic ! ( "should never happen" ) ,
580
580
} ;
581
+ let name = names_pos[ index] ;
582
+ let span = spans_pos[ index] ;
581
583
counts. push ( Context :: format_arg ( self . ecx , self . macsp , span, & Count , name) ) ;
582
584
}
583
585
0 commit comments