88// option. This file may not be copied, modified, or distributed
99// except according to those terms.
1010
11- use { Module , ModuleKind , Resolver } ;
11+ use { Module , ModuleKind , NameBinding , NameBindingKind , Resolver } ;
1212use build_reduced_graph:: BuildReducedGraphVisitor ;
1313use resolve_imports:: ImportResolver ;
1414use rustc:: hir:: def_id:: { DefId , BUILTIN_MACROS_CRATE , CRATE_DEF_INDEX , DefIndex } ;
1515use rustc:: hir:: def:: { Def , Export } ;
1616use rustc:: hir:: map:: { self , DefCollector } ;
17+ use rustc:: ty;
1718use std:: cell:: Cell ;
1819use std:: rc:: Rc ;
1920use syntax:: ast;
@@ -28,7 +29,7 @@ use syntax::parse::token::intern;
2829use syntax:: ptr:: P ;
2930use syntax:: util:: lev_distance:: find_best_match_for_name;
3031use syntax:: visit:: Visitor ;
31- use syntax_pos:: Span ;
32+ use syntax_pos:: { Span , DUMMY_SP } ;
3233
3334#[ derive( Clone ) ]
3435pub struct InvocationData < ' a > {
@@ -179,7 +180,12 @@ impl<'a> base::Resolver for Resolver<'a> {
179180 index : DefIndex :: new ( self . macro_map . len ( ) ) ,
180181 } ;
181182 self . macro_map . insert ( def_id, ext) ;
182- self . builtin_macros . insert ( ident. name , def_id) ;
183+ let binding = self . arenas . alloc_name_binding ( NameBinding {
184+ kind : NameBindingKind :: Def ( Def :: Macro ( def_id) ) ,
185+ span : DUMMY_SP ,
186+ vis : ty:: Visibility :: PrivateExternal ,
187+ } ) ;
188+ self . builtin_macros . insert ( ident. name , binding) ;
183189 }
184190
185191 fn add_expansions_at_stmt ( & mut self , id : ast:: NodeId , macros : Vec < Mark > ) {
@@ -193,8 +199,8 @@ impl<'a> base::Resolver for Resolver<'a> {
193199 fn find_attr_invoc ( & mut self , attrs : & mut Vec < ast:: Attribute > ) -> Option < ast:: Attribute > {
194200 for i in 0 ..attrs. len ( ) {
195201 let name = intern ( & attrs[ i] . name ( ) ) ;
196- match self . builtin_macros . get ( & name) {
197- Some ( & def_id ) => match * self . get_macro ( Def :: Macro ( def_id ) ) {
202+ match self . builtin_macros . get ( & name) . cloned ( ) {
203+ Some ( binding ) => match * self . get_macro ( binding . def ( ) ) {
198204 MultiModifier ( ..) | MultiDecorator ( ..) | SyntaxExtension :: AttrProcMacro ( ..) => {
199205 return Some ( attrs. remove ( i) )
200206 }
@@ -273,7 +279,7 @@ impl<'a> Resolver<'a> {
273279 if let Some ( scope) = possible_time_travel {
274280 self . lexical_macro_resolutions . push ( ( name, scope) ) ;
275281 }
276- self . builtin_macros . get ( & name) . cloned ( ) . map ( |def_id | self . get_macro ( Def :: Macro ( def_id ) ) )
282+ self . builtin_macros . get ( & name) . cloned ( ) . map ( |binding | self . get_macro ( binding . def ( ) ) )
277283 }
278284
279285 fn suggest_macro_name ( & mut self , name : & str , err : & mut DiagnosticBuilder < ' a > ) {
0 commit comments