@@ -79,11 +79,6 @@ impl ItemModifier for fn(&mut ExtCtxt, Span, Gc<ast::MetaItem>, Gc<ast::Item>) -
7979 }
8080}
8181
82- pub struct BasicMacroExpander {
83- pub expander : MacroExpanderFn ,
84- pub span : Option < Span >
85- }
86-
8782/// Represents a thing that maps token trees to Macro Results
8883pub trait TTMacroExpander {
8984 fn expand < ' cx > ( & self ,
@@ -94,24 +89,18 @@ pub trait TTMacroExpander {
9489}
9590
9691pub 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 > ;
9993
100- impl TTMacroExpander for BasicMacroExpander {
94+ impl TTMacroExpander for MacroExpanderFn {
10195 fn expand < ' cx > ( & self ,
10296 ecx : & ' cx mut ExtCtxt ,
10397 span : Span ,
10498 token_tree : & [ ast:: TokenTree ] )
10599 -> Box < MacResult +' cx > {
106- ( self . expander ) ( ecx , span , token_tree )
100+ ( * self) ( ecx , span , token_tree )
107101 }
108102}
109103
110- pub struct BasicIdentMacroExpander {
111- pub expander : IdentMacroExpanderFn ,
112- pub span : Option < Span >
113- }
114-
115104pub trait IdentMacroExpander {
116105 fn expand < ' cx > ( & self ,
117106 cx : & ' cx mut ExtCtxt ,
@@ -121,20 +110,20 @@ pub trait IdentMacroExpander {
121110 -> Box < MacResult +' cx > ;
122111}
123112
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 {
125117 fn expand < ' cx > ( & self ,
126118 cx : & ' cx mut ExtCtxt ,
127119 sp : Span ,
128120 ident : ast:: Ident ,
129121 token_tree : Vec < ast:: TokenTree > )
130122 -> Box < MacResult +' cx > {
131- ( self . expander ) ( cx , sp , ident , token_tree )
123+ ( * self) ( cx , sp , ident , token_tree )
132124 }
133125}
134126
135- pub type IdentMacroExpanderFn =
136- fn <' cx >( & ' cx mut ExtCtxt , Span , ast:: Ident , Vec < ast:: TokenTree > ) -> Box < MacResult +' cx > ;
137-
138127/// The result of a macro expansion. The return values of the various
139128 /// methods are spliced into the AST at the callsite of the macro ( or
140129/// just into the compiler's internal macro table, for `make_def`).
@@ -363,20 +352,12 @@ impl BlockInfo {
363352fn initial_syntax_expander_table ( ) -> SyntaxEnv {
364353 // utility function to simplify creating NormalTT syntax extensions
365354 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 )
371356 }
372357
373358 let mut syntax_expanders = SyntaxEnv :: new ( ) ;
374359 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 ) ) ;
380361 syntax_expanders. insert ( intern( "fmt" ) ,
381362 builtin_normal_expander (
382363 ext:: fmt:: expand_syntax_ext ) ) ;
0 commit comments