@@ -56,21 +56,7 @@ impl<'a, Id: Into<DefId>> ToNameBinding<'a>
5656impl < ' a , Id : Into < DefId > > ToNameBinding < ' a > for ( Res , ty:: Visibility < Id > , Span , LocalExpnId ) {
5757 fn to_name_binding ( self , arenas : & ' a ResolverArenas < ' a > ) -> & ' a NameBinding < ' a > {
5858 arenas. alloc_name_binding ( NameBinding {
59- kind : NameBindingKind :: Res ( self . 0 , false ) ,
60- ambiguity : None ,
61- vis : self . 1 . to_def_id ( ) ,
62- span : self . 2 ,
63- expansion : self . 3 ,
64- } )
65- }
66- }
67-
68- struct IsMacroExport ;
69-
70- impl < ' a > ToNameBinding < ' a > for ( Res , ty:: Visibility , Span , LocalExpnId , IsMacroExport ) {
71- fn to_name_binding ( self , arenas : & ' a ResolverArenas < ' a > ) -> & ' a NameBinding < ' a > {
72- arenas. alloc_name_binding ( NameBinding {
73- kind : NameBindingKind :: Res ( self . 0 , true ) ,
59+ kind : NameBindingKind :: Res ( self . 0 ) ,
7460 ambiguity : None ,
7561 vis : self . 1 . to_def_id ( ) ,
7662 span : self . 2 ,
@@ -364,7 +350,6 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
364350 module_path : Vec < Segment > ,
365351 kind : ImportKind < ' a > ,
366352 span : Span ,
367- id : NodeId ,
368353 item : & ast:: Item ,
369354 root_span : Span ,
370355 root_id : NodeId ,
@@ -377,7 +362,6 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
377362 module_path,
378363 imported_module : Cell :: new ( None ) ,
379364 span,
380- id,
381365 use_span : item. span ,
382366 use_span_with_attributes : item. span_with_attributes ( ) ,
383367 has_attributes : !item. attrs . is_empty ( ) ,
@@ -574,27 +558,20 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
574558 } ,
575559 type_ns_only,
576560 nested,
561+ id,
577562 additional_ids : ( id1, id2) ,
578563 } ;
579564
580- self . add_import (
581- module_path,
582- kind,
583- use_tree. span ,
584- id,
585- item,
586- root_span,
587- item. id ,
588- vis,
589- ) ;
565+ self . add_import ( module_path, kind, use_tree. span , item, root_span, item. id , vis) ;
590566 }
591567 ast:: UseTreeKind :: Glob => {
592568 let kind = ImportKind :: Glob {
593569 is_prelude : self . r . session . contains_name ( & item. attrs , sym:: prelude_import) ,
594570 max_vis : Cell :: new ( None ) ,
571+ id,
595572 } ;
596573 self . r . visibilities . insert ( self . r . local_def_id ( id) , vis) ;
597- self . add_import ( prefix, kind, use_tree. span , id , item, root_span, item. id , vis) ;
574+ self . add_import ( prefix, kind, use_tree. span , item, root_span, item. id , vis) ;
598575 }
599576 ast:: UseTreeKind :: Nested ( ref items) => {
600577 // Ensure there is at most one `self` in the list
@@ -881,9 +858,8 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
881858 } )
882859 . unwrap_or ( ( true , None , self . r . dummy_binding ) ) ;
883860 let import = self . r . arenas . alloc_import ( Import {
884- kind : ImportKind :: ExternCrate { source : orig_name, target : ident } ,
861+ kind : ImportKind :: ExternCrate { source : orig_name, target : ident, id : item . id } ,
885862 root_id : item. id ,
886- id : item. id ,
887863 parent_scope : self . parent_scope ,
888864 imported_module : Cell :: new ( module) ,
889865 has_attributes : !item. attrs . is_empty ( ) ,
@@ -1118,7 +1094,6 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
11181094 this. r . arenas . alloc_import ( Import {
11191095 kind : ImportKind :: MacroUse ,
11201096 root_id : item. id ,
1121- id : item. id ,
11221097 parent_scope : this. parent_scope ,
11231098 imported_module : Cell :: new ( Some ( ModuleOrUniformRoot :: Module ( module) ) ) ,
11241099 use_span_with_attributes : item. span_with_attributes ( ) ,
@@ -1278,8 +1253,22 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
12781253 let binding = ( res, vis, span, expansion) . to_name_binding ( self . r . arenas ) ;
12791254 self . r . set_binding_parent_module ( binding, parent_scope. module ) ;
12801255 if is_macro_export {
1281- let module = self . r . graph_root ;
1282- self . r . define ( module, ident, MacroNS , ( res, vis, span, expansion, IsMacroExport ) ) ;
1256+ let import = self . r . arenas . alloc_import ( Import {
1257+ kind : ImportKind :: MacroExport ,
1258+ root_id : item. id ,
1259+ parent_scope : self . parent_scope ,
1260+ imported_module : Cell :: new ( None ) ,
1261+ has_attributes : false ,
1262+ use_span_with_attributes : span,
1263+ use_span : span,
1264+ root_span : span,
1265+ span : span,
1266+ module_path : Vec :: new ( ) ,
1267+ vis : Cell :: new ( Some ( vis) ) ,
1268+ used : Cell :: new ( true ) ,
1269+ } ) ;
1270+ let import_binding = self . r . import ( binding, import) ;
1271+ self . r . define ( self . r . graph_root , ident, MacroNS , import_binding) ;
12831272 } else {
12841273 self . r . check_reserved_macro_name ( ident, res) ;
12851274 self . insert_unused_macro ( ident, def_id, item. id , & rule_spans) ;
0 commit comments