8
8
// option. This file may not be copied, modified, or distributed
9
9
// except according to those terms.
10
10
11
- use { Module , ModuleKind , Resolver } ;
11
+ use { Module , ModuleKind , NameBinding , NameBindingKind , Resolver } ;
12
12
use build_reduced_graph:: BuildReducedGraphVisitor ;
13
13
use resolve_imports:: ImportResolver ;
14
14
use rustc:: hir:: def_id:: { DefId , BUILTIN_MACROS_CRATE , CRATE_DEF_INDEX , DefIndex } ;
15
15
use rustc:: hir:: def:: { Def , Export } ;
16
16
use rustc:: hir:: map:: { self , DefCollector } ;
17
+ use rustc:: ty;
17
18
use std:: cell:: Cell ;
18
19
use std:: rc:: Rc ;
19
20
use syntax:: ast;
@@ -28,7 +29,7 @@ use syntax::parse::token::intern;
28
29
use syntax:: ptr:: P ;
29
30
use syntax:: util:: lev_distance:: find_best_match_for_name;
30
31
use syntax:: visit:: Visitor ;
31
- use syntax_pos:: Span ;
32
+ use syntax_pos:: { Span , DUMMY_SP } ;
32
33
33
34
#[ derive( Clone ) ]
34
35
pub struct InvocationData < ' a > {
@@ -179,7 +180,12 @@ impl<'a> base::Resolver for Resolver<'a> {
179
180
index : DefIndex :: new ( self . macro_map . len ( ) ) ,
180
181
} ;
181
182
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) ;
183
189
}
184
190
185
191
fn add_expansions_at_stmt ( & mut self , id : ast:: NodeId , macros : Vec < Mark > ) {
@@ -193,8 +199,8 @@ impl<'a> base::Resolver for Resolver<'a> {
193
199
fn find_attr_invoc ( & mut self , attrs : & mut Vec < ast:: Attribute > ) -> Option < ast:: Attribute > {
194
200
for i in 0 ..attrs. len ( ) {
195
201
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 ( ) ) {
198
204
MultiModifier ( ..) | MultiDecorator ( ..) | SyntaxExtension :: AttrProcMacro ( ..) => {
199
205
return Some ( attrs. remove ( i) )
200
206
}
@@ -273,7 +279,7 @@ impl<'a> Resolver<'a> {
273
279
if let Some ( scope) = possible_time_travel {
274
280
self . lexical_macro_resolutions . push ( ( name, scope) ) ;
275
281
}
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 ( ) ) )
277
283
}
278
284
279
285
fn suggest_macro_name ( & mut self , name : & str , err : & mut DiagnosticBuilder < ' a > ) {
0 commit comments