@@ -19,7 +19,7 @@ use syntax::ext::base;
1919use syntax:: ext:: build:: AstBuilder ;
2020use syntax:: parse:: token;
2121use syntax:: ptr:: P ;
22- use syntax:: symbol:: { Symbol , keywords } ;
22+ use syntax:: symbol:: Symbol ;
2323use syntax_pos:: { Span , DUMMY_SP } ;
2424use syntax:: tokenstream;
2525
@@ -501,32 +501,6 @@ impl<'a, 'b> Context<'a, 'b> {
501501 }
502502 }
503503
504- fn static_array ( ecx : & mut ExtCtxt ,
505- name : & str ,
506- piece_ty : P < ast:: Ty > ,
507- pieces : Vec < P < ast:: Expr > > )
508- -> P < ast:: Expr > {
509- let sp = piece_ty. span ;
510- let ty = ecx. ty_rptr ( sp,
511- ecx. ty ( sp, ast:: TyKind :: Slice ( piece_ty) ) ,
512- Some ( ecx. lifetime ( sp, keywords:: StaticLifetime . ident ( ) ) ) ,
513- ast:: Mutability :: Immutable ) ;
514- let slice = ecx. expr_vec_slice ( sp, pieces) ;
515- // static instead of const to speed up codegen by not requiring this to be inlined
516- let st = ast:: ItemKind :: Static ( ty, ast:: Mutability :: Immutable , slice) ;
517-
518- let name = ecx. ident_of ( name) ;
519- let item = ecx. item ( sp, name, vec ! [ ] , st) ;
520- let stmt = ast:: Stmt {
521- id : ast:: DUMMY_NODE_ID ,
522- node : ast:: StmtKind :: Item ( item) ,
523- span : sp,
524- } ;
525-
526- // Wrap the declaration in a block so that it forms a single expression.
527- ecx. expr_block ( ecx. block ( sp, vec ! [ stmt, ecx. stmt_expr( ecx. expr_ident( sp, name) ) ] ) )
528- }
529-
530504 /// Actually builds the expression which the format_args! block will be
531505 /// expanded to
532506 fn into_expr ( self ) -> P < ast:: Expr > {
@@ -537,12 +511,7 @@ impl<'a, 'b> Context<'a, 'b> {
537511
538512 // First, build up the static array which will become our precompiled
539513 // format "string"
540- let static_lifetime = self . ecx . lifetime ( self . fmtsp , keywords:: StaticLifetime . ident ( ) ) ;
541- let piece_ty = self . ecx . ty_rptr ( self . fmtsp ,
542- self . ecx . ty_ident ( self . fmtsp , self . ecx . ident_of ( "str" ) ) ,
543- Some ( static_lifetime) ,
544- ast:: Mutability :: Immutable ) ;
545- let pieces = Context :: static_array ( self . ecx , "__STATIC_FMTSTR" , piece_ty, self . str_pieces ) ;
514+ let pieces = self . ecx . expr_vec_slice ( self . fmtsp , self . str_pieces ) ;
546515
547516 // Before consuming the expressions, we have to remember spans for
548517 // count arguments as they are now generated separate from other
@@ -623,9 +592,7 @@ impl<'a, 'b> Context<'a, 'b> {
623592 } else {
624593 // Build up the static array which will store our precompiled
625594 // nonstandard placeholders, if there are any.
626- let piece_ty = self . ecx
627- . ty_path ( self . ecx . path_global ( self . macsp , Context :: rtpath ( self . ecx , "Argument" ) ) ) ;
628- let fmt = Context :: static_array ( self . ecx , "__STATIC_FMTARGS" , piece_ty, self . pieces ) ;
595+ let fmt = self . ecx . expr_vec_slice ( self . macsp , self . pieces ) ;
629596
630597 ( "new_v1_formatted" , vec ! [ pieces, args_slice, fmt] )
631598 } ;
0 commit comments