@@ -17,12 +17,11 @@ use syntax::errors::DiagnosticBuilder;
1717use syntax:: ext:: base:: { self , Determinacy } ;
1818use syntax:: ext:: base:: { MacroKind , SyntaxExtension } ;
1919use syntax:: ext:: expand:: { AstFragment , Invocation , InvocationKind } ;
20- use syntax:: ext:: hygiene:: Mark ;
20+ use syntax:: ext:: hygiene:: { self , Mark } ;
2121use syntax:: ext:: tt:: macro_rules;
2222use syntax:: feature_gate:: { feature_err, emit_feature_err, is_builtin_attr_name} ;
2323use syntax:: feature_gate:: { AttributeGate , GateIssue , Stability , BUILTIN_ATTRIBUTES } ;
2424use syntax:: symbol:: { Symbol , kw, sym} ;
25- use syntax:: visit:: Visitor ;
2625use syntax:: util:: lev_distance:: find_best_match_for_name;
2726use syntax_pos:: { Span , DUMMY_SP } ;
2827use errors:: Applicability ;
@@ -146,24 +145,14 @@ impl<'a> base::Resolver for Resolver<'a> {
146145 mark
147146 }
148147
149- fn resolve_dollar_crates ( & mut self , fragment : & AstFragment ) {
150- struct ResolveDollarCrates < ' a , ' b > {
151- resolver : & ' a mut Resolver < ' b >
152- }
153- impl < ' a > Visitor < ' a > for ResolveDollarCrates < ' a , ' _ > {
154- fn visit_ident ( & mut self , ident : Ident ) {
155- if ident. name == kw:: DollarCrate {
156- let name = match self . resolver . resolve_crate_root ( ident) . kind {
157- ModuleKind :: Def ( .., name) if name != kw:: Invalid => name,
158- _ => kw:: Crate ,
159- } ;
160- ident. span . ctxt ( ) . set_dollar_crate_name ( name) ;
161- }
148+ fn resolve_dollar_crates ( & mut self ) {
149+ hygiene:: update_dollar_crate_names ( |ctxt| {
150+ let ident = Ident :: new ( kw:: DollarCrate , DUMMY_SP . with_ctxt ( ctxt) ) ;
151+ match self . resolve_crate_root ( ident) . kind {
152+ ModuleKind :: Def ( .., name) if name != kw:: Invalid => name,
153+ _ => kw:: Crate ,
162154 }
163- fn visit_mac ( & mut self , _: & ast:: Mac ) { }
164- }
165-
166- fragment. visit_with ( & mut ResolveDollarCrates { resolver : self } ) ;
155+ } ) ;
167156 }
168157
169158 fn visit_ast_fragment_with_placeholders ( & mut self , mark : Mark , fragment : & AstFragment ,
0 commit comments