@@ -270,18 +270,6 @@ fn expand_mac_invoc(invoc: Invocation, fld: &mut MacroExpander) -> Expansion {
270
270
fully_expanded
271
271
}
272
272
273
- // eval $e with a new exts frame.
274
- // must be a macro so that $e isn't evaluated too early.
275
- macro_rules! with_exts_frame {
276
- ( $extsboxexpr: expr, $macros_escape: expr, $e: expr) =>
277
- ( { $extsboxexpr. push_frame( ) ;
278
- $extsboxexpr. info( ) . macros_escape = $macros_escape;
279
- let result = $e;
280
- $extsboxexpr. pop_frame( ) ;
281
- result
282
- } )
283
- }
284
-
285
273
// When we enter a module, record it, for the sake of `module!`
286
274
pub fn expand_item ( it : P < ast:: Item > , fld : & mut MacroExpander )
287
275
-> SmallVector < P < ast:: Item > > {
@@ -378,9 +366,7 @@ fn expand_multi_modified(a: Annotatable, fld: &mut MacroExpander) -> SmallVector
378
366
fld. cx . mod_push ( it. ident ) ;
379
367
}
380
368
let macro_use = contains_macro_use ( fld, & it. attrs ) ;
381
- let result = with_exts_frame ! ( fld. cx. syntax_env,
382
- macro_use,
383
- noop_fold_item( it, fld) ) ;
369
+ let result = fld. with_exts_frame ( macro_use, |fld| noop_fold_item ( it, fld) ) ;
384
370
if valid_ident {
385
371
fld. cx . mod_pop ( ) ;
386
372
}
@@ -561,6 +547,14 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
561
547
let mark = Mark :: fresh ( ) ;
562
548
Invocation { span : span, attrs : attrs, mac : mac, mark : mark, kind : kind, ident : None }
563
549
}
550
+
551
+ fn with_exts_frame < T , F : FnOnce ( & mut Self ) -> T > ( & mut self , macros_escape : bool , f : F ) -> T {
552
+ self . cx . syntax_env . push_frame ( ) ;
553
+ self . cx . syntax_env . info ( ) . macros_escape = macros_escape;
554
+ let result = f ( self ) ;
555
+ self . cx . syntax_env . pop_frame ( ) ;
556
+ result
557
+ }
564
558
}
565
559
566
560
impl < ' a , ' b > Folder for MacroExpander < ' a , ' b > {
@@ -624,7 +618,7 @@ impl<'a, 'b> Folder for MacroExpander<'a, 'b> {
624
618
625
619
fn fold_block ( & mut self , block : P < Block > ) -> P < Block > {
626
620
let was_in_block = :: std:: mem:: replace ( & mut self . cx . in_block , true ) ;
627
- let result = with_exts_frame ! ( self . cx . syntax_env , false , noop_fold_block( block, self ) ) ;
621
+ let result = self . with_exts_frame ( false , |this| noop_fold_block ( block, this ) ) ;
628
622
self . cx . in_block = was_in_block;
629
623
result
630
624
}
0 commit comments