@@ -763,13 +763,8 @@ impl<'a, 'b> Context<'a, 'b> {
763
763
let mut locals =
764
764
Vec :: with_capacity ( ( 0 ..self . args . len ( ) ) . map ( |i| self . arg_unique_types [ i] . len ( ) ) . sum ( ) ) ;
765
765
let mut counts = Vec :: with_capacity ( self . count_args . len ( ) ) ;
766
- let mut pats = Vec :: with_capacity ( self . args . len ( ) ) ;
767
766
let mut heads = Vec :: with_capacity ( self . args . len ( ) ) ;
768
767
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
-
773
768
// First, build up the static array which will become our precompiled
774
769
// format "string"
775
770
let pieces = self . ecx . expr_vec_slice ( self . fmtsp , self . str_pieces ) ;
@@ -787,11 +782,8 @@ impl<'a, 'b> Context<'a, 'b> {
787
782
// of each variable because we don't want to move out of the arguments
788
783
// passed to this function.
789
784
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) ) ;
793
785
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 ) ) ;
795
787
}
796
788
heads. push ( self . ecx . expr_addr_of ( e. span , e) ) ;
797
789
}
@@ -800,9 +792,8 @@ impl<'a, 'b> Context<'a, 'b> {
800
792
Exact ( i) => i,
801
793
_ => panic ! ( "should never happen" ) ,
802
794
} ;
803
- let name = names_pos[ index] ;
804
795
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 ) ) ;
806
797
}
807
798
808
799
// Now create a vector containing all the arguments
@@ -838,7 +829,7 @@ impl<'a, 'b> Context<'a, 'b> {
838
829
// But the nested match expression is proved to perform not as well
839
830
// as series of let's; the first approach does.
840
831
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 ) ) ;
842
833
let arm = self . ecx . arm ( self . macsp , pat, args_array) ;
843
834
let head = self . ecx . expr ( self . macsp , ast:: ExprKind :: Tup ( heads) ) ;
844
835
self . ecx . expr_match ( self . macsp , head, vec ! [ arm] )
@@ -877,10 +868,11 @@ impl<'a, 'b> Context<'a, 'b> {
877
868
macsp : Span ,
878
869
mut sp : Span ,
879
870
ty : & ArgumentType ,
880
- arg : Ident ,
871
+ arg_index : usize ,
881
872
) -> P < ast:: Expr > {
882
873
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) ) ) ;
884
876
let trait_ = match * ty {
885
877
Placeholder ( trait_) if trait_ == "<invalid>" => return DummyResult :: raw_expr ( sp, true ) ,
886
878
Placeholder ( trait_) => trait_,
0 commit comments