@@ -79,11 +79,6 @@ impl ItemModifier for fn(&mut ExtCtxt, Span, Gc<ast::MetaItem>, Gc<ast::Item>) -
79
79
}
80
80
}
81
81
82
- pub struct BasicMacroExpander {
83
- pub expander : MacroExpanderFn ,
84
- pub span : Option < Span >
85
- }
86
-
87
82
/// Represents a thing that maps token trees to Macro Results
88
83
pub trait TTMacroExpander {
89
84
fn expand < ' cx > ( & self ,
@@ -94,24 +89,18 @@ pub trait TTMacroExpander {
94
89
}
95
90
96
91
pub type MacroExpanderFn =
97
- fn <' cx >( ecx : & ' cx mut ExtCtxt , span : codemap:: Span , token_tree : & [ ast:: TokenTree ] )
98
- -> Box < MacResult +' cx > ;
92
+ fn <' cx >( & ' cx mut ExtCtxt , Span , & [ ast:: TokenTree ] ) -> Box < MacResult +' cx > ;
99
93
100
- impl TTMacroExpander for BasicMacroExpander {
94
+ impl TTMacroExpander for MacroExpanderFn {
101
95
fn expand < ' cx > ( & self ,
102
96
ecx : & ' cx mut ExtCtxt ,
103
97
span : Span ,
104
98
token_tree : & [ ast:: TokenTree ] )
105
99
-> Box < MacResult +' cx > {
106
- ( self . expander ) ( ecx , span , token_tree )
100
+ ( * self) ( ecx , span , token_tree )
107
101
}
108
102
}
109
103
110
- pub struct BasicIdentMacroExpander {
111
- pub expander : IdentMacroExpanderFn ,
112
- pub span : Option < Span >
113
- }
114
-
115
104
pub trait IdentMacroExpander {
116
105
fn expand < ' cx > ( & self ,
117
106
cx : & ' cx mut ExtCtxt ,
@@ -121,20 +110,20 @@ pub trait IdentMacroExpander {
121
110
-> Box < MacResult +' cx > ;
122
111
}
123
112
124
- impl IdentMacroExpander for BasicIdentMacroExpander {
113
+ pub type IdentMacroExpanderFn =
114
+ fn <' cx >( & ' cx mut ExtCtxt , Span , ast:: Ident , Vec < ast:: TokenTree > ) -> Box < MacResult +' cx > ;
115
+
116
+ impl IdentMacroExpander for IdentMacroExpanderFn {
125
117
fn expand < ' cx > ( & self ,
126
118
cx : & ' cx mut ExtCtxt ,
127
119
sp : Span ,
128
120
ident : ast:: Ident ,
129
121
token_tree : Vec < ast:: TokenTree > )
130
122
-> Box < MacResult +' cx > {
131
- ( self . expander ) ( cx , sp , ident , token_tree )
123
+ ( * self) ( cx , sp , ident , token_tree )
132
124
}
133
125
}
134
126
135
- pub type IdentMacroExpanderFn =
136
- fn <' cx >( & ' cx mut ExtCtxt , Span , ast:: Ident , Vec < ast:: TokenTree > ) -> Box < MacResult +' cx > ;
137
-
138
127
/// The result of a macro expansion. The return values of the various
139
128
/// methods are spliced into the AST at the callsite of the macro ( or
140
129
/// just into the compiler's internal macro table, for `make_def`).
@@ -363,20 +352,12 @@ impl BlockInfo {
363
352
fn initial_syntax_expander_table ( ) -> SyntaxEnv {
364
353
// utility function to simplify creating NormalTT syntax extensions
365
354
fn builtin_normal_expander ( f : MacroExpanderFn ) -> SyntaxExtension {
366
- NormalTT ( box BasicMacroExpander {
367
- expander : f,
368
- span : None ,
369
- } ,
370
- None )
355
+ NormalTT ( box f, None )
371
356
}
372
357
373
358
let mut syntax_expanders = SyntaxEnv :: new ( ) ;
374
359
syntax_expanders. insert ( intern( "macro_rules" ) ,
375
- LetSyntaxTT ( box BasicIdentMacroExpander {
376
- expander : ext:: tt:: macro_rules:: add_new_extension,
377
- span : None ,
378
- } ,
379
- None ) ) ;
360
+ LetSyntaxTT ( box ext:: tt:: macro_rules:: add_new_extension , None ) ) ;
380
361
syntax_expanders. insert ( intern( "fmt" ) ,
381
362
builtin_normal_expander (
382
363
ext:: fmt:: expand_syntax_ext ) ) ;
0 commit comments