@@ -19,7 +19,7 @@ use syntax::ext::base;
19
19
use syntax:: ext:: build:: AstBuilder ;
20
20
use syntax:: parse:: token;
21
21
use syntax:: ptr:: P ;
22
- use syntax:: symbol:: { Symbol , keywords } ;
22
+ use syntax:: symbol:: Symbol ;
23
23
use syntax_pos:: { Span , DUMMY_SP } ;
24
24
use syntax:: tokenstream;
25
25
@@ -501,32 +501,6 @@ impl<'a, 'b> Context<'a, 'b> {
501
501
}
502
502
}
503
503
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
-
530
504
/// Actually builds the expression which the format_args! block will be
531
505
/// expanded to
532
506
fn into_expr ( self ) -> P < ast:: Expr > {
@@ -537,12 +511,7 @@ impl<'a, 'b> Context<'a, 'b> {
537
511
538
512
// First, build up the static array which will become our precompiled
539
513
// 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 ) ;
546
515
547
516
// Before consuming the expressions, we have to remember spans for
548
517
// count arguments as they are now generated separate from other
@@ -623,9 +592,7 @@ impl<'a, 'b> Context<'a, 'b> {
623
592
} else {
624
593
// Build up the static array which will store our precompiled
625
594
// 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 ) ;
629
596
630
597
( "new_v1_formatted" , vec ! [ pieces, args_slice, fmt] )
631
598
} ;
0 commit comments