@@ -3,8 +3,8 @@ use Position::*;
3
3
4
4
use rustc_ast as ast;
5
5
use rustc_ast:: ptr:: P ;
6
+ use rustc_ast:: token;
6
7
use rustc_ast:: tokenstream:: TokenStream ;
7
- use rustc_ast:: { token, BlockCheckMode , UnsafeSource } ;
8
8
use rustc_data_structures:: fx:: { FxHashMap , FxHashSet } ;
9
9
use rustc_errors:: { pluralize, Applicability , DiagnosticBuilder } ;
10
10
use rustc_expand:: base:: { self , * } ;
@@ -837,15 +837,12 @@ impl<'a, 'b> Context<'a, 'b> {
837
837
//
838
838
// But the nested match expression is proved to perform not as well
839
839
// 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] ) ;
846
844
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) ;
849
846
850
847
// Now create the fmt::Arguments struct with all our locals we created.
851
848
let ( fn_name, fn_args) = if self . all_pieces_simple {
@@ -859,21 +856,7 @@ impl<'a, 'b> Context<'a, 'b> {
859
856
} ;
860
857
861
858
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)
877
860
}
878
861
879
862
fn format_arg (
0 commit comments