@@ -763,13 +763,8 @@ impl<'a, 'b> Context<'a, 'b> {
763763 let mut locals =
764764 Vec :: with_capacity ( ( 0 ..self . args . len ( ) ) . map ( |i| self . arg_unique_types [ i] . len ( ) ) . sum ( ) ) ;
765765 let mut counts = Vec :: with_capacity ( self . count_args . len ( ) ) ;
766- let mut pats = Vec :: with_capacity ( self . args . len ( ) ) ;
767766 let mut heads = Vec :: with_capacity ( self . args . len ( ) ) ;
768767
769- let names_pos: Vec < _ > = ( 0 ..self . args . len ( ) )
770- . map ( |i| Ident :: from_str_and_span ( & format ! ( "arg{}" , i) , self . macsp ) )
771- . collect ( ) ;
772-
773768 // First, build up the static array which will become our precompiled
774769 // format "string"
775770 let pieces = self . ecx . expr_vec_slice ( self . fmtsp , self . str_pieces ) ;
@@ -787,11 +782,8 @@ impl<'a, 'b> Context<'a, 'b> {
787782 // of each variable because we don't want to move out of the arguments
788783 // passed to this function.
789784 for ( i, e) in self . args . into_iter ( ) . enumerate ( ) {
790- let name = names_pos[ i] ;
791- let span = self . ecx . with_def_site_ctxt ( e. span ) ;
792- pats. push ( self . ecx . pat_ident ( span, name) ) ;
793785 for arg_ty in self . arg_unique_types [ i] . iter ( ) {
794- locals. push ( Context :: format_arg ( self . ecx , self . macsp , e. span , arg_ty, name ) ) ;
786+ locals. push ( Context :: format_arg ( self . ecx , self . macsp , e. span , arg_ty, i ) ) ;
795787 }
796788 heads. push ( self . ecx . expr_addr_of ( e. span , e) ) ;
797789 }
@@ -800,9 +792,8 @@ impl<'a, 'b> Context<'a, 'b> {
800792 Exact ( i) => i,
801793 _ => panic ! ( "should never happen" ) ,
802794 } ;
803- let name = names_pos[ index] ;
804795 let span = spans_pos[ index] ;
805- counts. push ( Context :: format_arg ( self . ecx , self . macsp , span, & Count , name ) ) ;
796+ counts. push ( Context :: format_arg ( self . ecx , self . macsp , span, & Count , index ) ) ;
806797 }
807798
808799 // Now create a vector containing all the arguments
@@ -838,7 +829,7 @@ impl<'a, 'b> Context<'a, 'b> {
838829 // But the nested match expression is proved to perform not as well
839830 // as series of let's; the first approach does.
840831 let args_match = {
841- let pat = self . ecx . pat_tuple ( self . macsp , pats ) ;
832+ let pat = self . ecx . pat_ident ( self . macsp , Ident :: new ( sym :: _args , self . macsp ) ) ;
842833 let arm = self . ecx . arm ( self . macsp , pat, args_array) ;
843834 let head = self . ecx . expr ( self . macsp , ast:: ExprKind :: Tup ( heads) ) ;
844835 self . ecx . expr_match ( self . macsp , head, vec ! [ arm] )
@@ -877,10 +868,11 @@ impl<'a, 'b> Context<'a, 'b> {
877868 macsp : Span ,
878869 mut sp : Span ,
879870 ty : & ArgumentType ,
880- arg : Ident ,
871+ arg_index : usize ,
881872 ) -> P < ast:: Expr > {
882873 sp = ecx. with_def_site_ctxt ( sp) ;
883- let arg = ecx. expr_ident ( sp, arg) ;
874+ let arg = ecx. expr_ident ( sp, Ident :: new ( sym:: _args, sp) ) ;
875+ let arg = ecx. expr ( sp, ast:: ExprKind :: Field ( arg, Ident :: new ( sym:: integer ( arg_index) , sp) ) ) ;
884876 let trait_ = match * ty {
885877 Placeholder ( trait_) if trait_ == "<invalid>" => return DummyResult :: raw_expr ( sp, true ) ,
886878 Placeholder ( trait_) => trait_,
0 commit comments