99// except according to those terms.
1010
1111use ast:: { Block , Crate , Ident , Mac_ , Name , PatKind } ;
12- use ast:: { MacStmtStyle , Mrk , Stmt , StmtKind , ItemKind } ;
12+ use ast:: { MacStmtStyle , Stmt , StmtKind , ItemKind } ;
1313use ast;
14- use attr:: HasAttrs ;
15- use ext:: mtwt;
16- use attr;
14+ use ext:: hygiene:: Mark ;
15+ use attr:: { self , HasAttrs } ;
1716use attr:: AttrMetaMethods ;
18- use codemap:: { dummy_spanned, Spanned , ExpnInfo , NameAndSpan , MacroBang , MacroAttribute } ;
17+ use codemap:: { dummy_spanned, ExpnInfo , NameAndSpan , MacroBang , MacroAttribute } ;
1918use syntax_pos:: { self , Span , ExpnId } ;
2019use config:: StripUnconfigured ;
2120use ext:: base:: * ;
2221use feature_gate:: { self , Features } ;
2322use fold;
2423use fold:: * ;
25- use parse:: token:: { fresh_mark , intern, keywords} ;
24+ use parse:: token:: { intern, keywords} ;
2625use ptr:: P ;
2726use tokenstream:: TokenTree ;
2827use util:: small_vector:: SmallVector ;
@@ -130,9 +129,9 @@ fn expand_mac_invoc<T>(mac: ast::Mac, ident: Option<Ident>, attrs: Vec<ast::Attr
130129 // It would almost certainly be cleaner to pass the whole macro invocation in,
131130 // rather than pulling it apart and marking the tts and the ctxt separately.
132131 let Mac_ { path, tts, .. } = mac. node ;
133- let mark = fresh_mark ( ) ;
132+ let mark = Mark :: fresh ( ) ;
134133
135- fn mac_result < ' a > ( path : & ast:: Path , ident : Option < Ident > , tts : Vec < TokenTree > , mark : Mrk ,
134+ fn mac_result < ' a > ( path : & ast:: Path , ident : Option < Ident > , tts : Vec < TokenTree > , mark : Mark ,
136135 attrs : Vec < ast:: Attribute > , call_site : Span , fld : & ' a mut MacroExpander )
137136 -> Option < Box < MacResult + ' a > > {
138137 // Detect use of feature-gated or invalid attributes on macro invoations
@@ -708,30 +707,17 @@ pub fn expand_crate(mut cx: ExtCtxt,
708707 return ( ret, cx. syntax_env . names ) ;
709708}
710709
711- // HYGIENIC CONTEXT EXTENSION:
712- // all of these functions are for walking over
713- // ASTs and making some change to the context of every
714- // element that has one. a CtxtFn is a trait-ified
715- // version of a closure in (SyntaxContext -> SyntaxContext).
716- // the ones defined here include:
717- // Marker - add a mark to a context
718-
719710// A Marker adds the given mark to the syntax context and
720711// sets spans' `expn_id` to the given expn_id (unless it is `None`).
721- struct Marker { mark : Mrk , expn_id : Option < ExpnId > }
712+ struct Marker { mark : Mark , expn_id : Option < ExpnId > }
722713
723714impl Folder for Marker {
724- fn fold_ident ( & mut self , id : Ident ) -> Ident {
725- ast:: Ident :: new ( id. name , mtwt:: apply_mark ( self . mark , id. ctxt ) )
726- }
727- fn fold_mac ( & mut self , Spanned { node, span} : ast:: Mac ) -> ast:: Mac {
728- Spanned {
729- node : Mac_ {
730- path : self . fold_path ( node. path ) ,
731- tts : self . fold_tts ( & node. tts ) ,
732- } ,
733- span : self . new_span ( span) ,
734- }
715+ fn fold_ident ( & mut self , mut ident : Ident ) -> Ident {
716+ ident. ctxt = ident. ctxt . apply_mark ( self . mark ) ;
717+ ident
718+ }
719+ fn fold_mac ( & mut self , mac : ast:: Mac ) -> ast:: Mac {
720+ noop_fold_mac ( mac, self )
735721 }
736722
737723 fn new_span ( & mut self , mut span : Span ) -> Span {
@@ -743,7 +729,7 @@ impl Folder for Marker {
743729}
744730
745731// apply a given mark to the given token trees. Used prior to expansion of a macro.
746- fn mark_tts ( tts : & [ TokenTree ] , m : Mrk ) -> Vec < TokenTree > {
732+ fn mark_tts ( tts : & [ TokenTree ] , m : Mark ) -> Vec < TokenTree > {
747733 noop_fold_tts ( tts, & mut Marker { mark : m, expn_id : None } )
748734}
749735
0 commit comments