@@ -3,8 +3,8 @@ use Position::*;
33
44use rustc_ast as ast;
55use rustc_ast:: ptr:: P ;
6+ use rustc_ast:: token;
67use rustc_ast:: tokenstream:: TokenStream ;
7- use rustc_ast:: { token, BlockCheckMode , UnsafeSource } ;
88use rustc_data_structures:: fx:: { FxHashMap , FxHashSet } ;
99use rustc_errors:: { pluralize, Applicability , DiagnosticBuilder } ;
1010use rustc_expand:: base:: { self , * } ;
@@ -837,15 +837,12 @@ impl<'a, 'b> Context<'a, 'b> {
837837 //
838838 // But the nested match expression is proved to perform not as well
839839 // as series of let's; the first approach does.
840- let args_match = {
841- let pat = self . ecx . pat_tuple ( self . macsp , pats) ;
842- let arm = self . ecx . arm ( self . macsp , pat, args_array) ;
843- let head = self . ecx . expr ( self . macsp , ast:: ExprKind :: Tup ( heads) ) ;
844- self . ecx . expr_match ( self . macsp , head, vec ! [ arm] )
845- } ;
840+ let pat = self . ecx . pat_tuple ( self . macsp , pats) ;
841+ let arm = self . ecx . arm ( self . macsp , pat, args_array) ;
842+ let head = self . ecx . expr ( self . macsp , ast:: ExprKind :: Tup ( heads) ) ;
843+ let result = self . ecx . expr_match ( self . macsp , head, vec ! [ arm] ) ;
846844
847- let ident = Ident :: from_str_and_span ( "args" , self . macsp ) ;
848- let args_slice = self . ecx . expr_ident ( self . macsp , ident) ;
845+ let args_slice = self . ecx . expr_addr_of ( self . macsp , result) ;
849846
850847 // Now create the fmt::Arguments struct with all our locals we created.
851848 let ( fn_name, fn_args) = if self . all_pieces_simple {
@@ -859,21 +856,7 @@ impl<'a, 'b> Context<'a, 'b> {
859856 } ;
860857
861858 let path = self . ecx . std_path ( & [ sym:: fmt, sym:: Arguments , Symbol :: intern ( fn_name) ] ) ;
862- let arguments = self . ecx . expr_call_global ( self . macsp , path, fn_args) ;
863- let body = self . ecx . expr_block ( P ( ast:: Block {
864- stmts : vec ! [ self . ecx. stmt_expr( arguments) ] ,
865- id : ast:: DUMMY_NODE_ID ,
866- rules : BlockCheckMode :: Unsafe ( UnsafeSource :: CompilerGenerated ) ,
867- span : self . macsp ,
868- tokens : None ,
869- could_be_bare_literal : false ,
870- } ) ) ;
871-
872- let ident = Ident :: from_str_and_span ( "args" , self . macsp ) ;
873- let binding_mode = ast:: BindingMode :: ByRef ( ast:: Mutability :: Not ) ;
874- let pat = self . ecx . pat_ident_binding_mode ( self . macsp , ident, binding_mode) ;
875- let arm = self . ecx . arm ( self . macsp , pat, body) ;
876- self . ecx . expr_match ( self . macsp , args_match, vec ! [ arm] )
859+ self . ecx . expr_call_global ( self . macsp , path, fn_args)
877860 }
878861
879862 fn format_arg (
0 commit comments