@@ -12,7 +12,7 @@ use ast::{Block, Crate, Ident, Mac_, PatKind};
12
12
use ast:: { MacStmtStyle , StmtKind , ItemKind } ;
13
13
use ast;
14
14
use ext:: hygiene:: Mark ;
15
- use ext:: placeholders:: { self , placeholder, PlaceholderExpander } ;
15
+ use ext:: placeholders:: { placeholder, PlaceholderExpander } ;
16
16
use attr:: { self , HasAttrs } ;
17
17
use codemap:: { ExpnInfo , NameAndSpan , MacroBang , MacroAttribute } ;
18
18
use syntax_pos:: { self , Span , ExpnId } ;
@@ -173,19 +173,12 @@ impl Invocation {
173
173
174
174
pub struct MacroExpander < ' a , ' b : ' a > {
175
175
pub cx : & ' a mut ExtCtxt < ' b > ,
176
- pub single_step : bool ,
177
- pub keep_macs : bool ,
178
176
monotonic : bool , // c.f. `cx.monotonic_expander()`
179
177
}
180
178
181
179
impl < ' a , ' b > MacroExpander < ' a , ' b > {
182
180
pub fn new ( cx : & ' a mut ExtCtxt < ' b > , monotonic : bool ) -> Self {
183
- MacroExpander {
184
- cx : cx,
185
- monotonic : monotonic,
186
- single_step : false ,
187
- keep_macs : false ,
188
- }
181
+ MacroExpander { cx : cx, monotonic : monotonic }
189
182
}
190
183
191
184
fn expand_crate ( & mut self , mut krate : ast:: Crate ) -> ast:: Crate {
@@ -238,7 +231,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
238
231
expansions. push ( Vec :: new ( ) ) ;
239
232
}
240
233
expansions[ depth] . push ( ( mark. as_u32 ( ) , expansion) ) ;
241
- if !self . single_step {
234
+ if !self . cx . ecfg . single_step {
242
235
invocations. extend ( new_invocations. into_iter ( ) . rev ( ) ) ;
243
236
}
244
237
}
@@ -381,47 +374,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
381
374
}
382
375
} ) ;
383
376
384
- kind. make_from ( expander. expand ( self . cx , span, ident, marked_tts) )
385
- }
386
-
387
- MacroRulesTT => {
388
- if ident. name == keywords:: Invalid . name ( ) {
389
- self . cx . span_err ( path. span ,
390
- & format ! ( "macro {}! expects an ident argument" , extname) ) ;
391
- return kind. dummy ( span) ;
392
- } ;
393
-
394
- self . cx . bt_push ( ExpnInfo {
395
- call_site : span,
396
- callee : NameAndSpan {
397
- format : MacroBang ( extname) ,
398
- span : None ,
399
- // `macro_rules!` doesn't directly allow unstable
400
- // (this is orthogonal to whether the macro it creates allows it)
401
- allow_internal_unstable : false ,
402
- }
403
- } ) ;
404
-
405
- let def = ast:: MacroDef {
406
- ident : ident,
407
- id : ast:: DUMMY_NODE_ID ,
408
- span : span,
409
- imported_from : None ,
410
- use_locally : true ,
411
- body : marked_tts,
412
- export : attr:: contains_name ( & attrs, "macro_export" ) ,
413
- allow_internal_unstable : attr:: contains_name ( & attrs, "allow_internal_unstable" ) ,
414
- attrs : attrs,
415
- } ;
416
-
417
- self . cx . insert_macro ( def. clone ( ) ) ;
418
-
419
- // If keep_macs is true, expands to a MacEager::items instead.
420
- if self . keep_macs {
421
- Some ( placeholders:: reconstructed_macro_rules ( & def, & path) )
422
- } else {
423
- Some ( placeholders:: macro_scope_placeholder ( ) )
424
- }
377
+ kind. make_from ( expander. expand ( self . cx , span, ident, marked_tts, attrs) )
425
378
}
426
379
427
380
MultiDecorator ( ..) | MultiModifier ( ..) => {
@@ -726,6 +679,8 @@ pub struct ExpansionConfig<'feat> {
726
679
pub recursion_limit : usize ,
727
680
pub trace_mac : bool ,
728
681
pub should_test : bool , // If false, strip `#[test]` nodes
682
+ pub single_step : bool ,
683
+ pub keep_macs : bool ,
729
684
}
730
685
731
686
macro_rules! feature_tests {
@@ -749,6 +704,8 @@ impl<'feat> ExpansionConfig<'feat> {
749
704
recursion_limit : 64 ,
750
705
trace_mac : false ,
751
706
should_test : false ,
707
+ single_step : false ,
708
+ keep_macs : false ,
752
709
}
753
710
}
754
711
0 commit comments