@@ -56,21 +56,7 @@ impl<'a, Id: Into<DefId>> ToNameBinding<'a>
56
56
impl < ' a , Id : Into < DefId > > ToNameBinding < ' a > for ( Res , ty:: Visibility < Id > , Span , LocalExpnId ) {
57
57
fn to_name_binding ( self , arenas : & ' a ResolverArenas < ' a > ) -> & ' a NameBinding < ' a > {
58
58
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 ) ,
74
60
ambiguity : None ,
75
61
vis : self . 1 . to_def_id ( ) ,
76
62
span : self . 2 ,
@@ -364,7 +350,6 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
364
350
module_path : Vec < Segment > ,
365
351
kind : ImportKind < ' a > ,
366
352
span : Span ,
367
- id : NodeId ,
368
353
item : & ast:: Item ,
369
354
root_span : Span ,
370
355
root_id : NodeId ,
@@ -377,7 +362,6 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
377
362
module_path,
378
363
imported_module : Cell :: new ( None ) ,
379
364
span,
380
- id,
381
365
use_span : item. span ,
382
366
use_span_with_attributes : item. span_with_attributes ( ) ,
383
367
has_attributes : !item. attrs . is_empty ( ) ,
@@ -574,27 +558,20 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
574
558
} ,
575
559
type_ns_only,
576
560
nested,
561
+ id,
577
562
additional_ids : ( id1, id2) ,
578
563
} ;
579
564
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) ;
590
566
}
591
567
ast:: UseTreeKind :: Glob => {
592
568
let kind = ImportKind :: Glob {
593
569
is_prelude : self . r . session . contains_name ( & item. attrs , sym:: prelude_import) ,
594
570
max_vis : Cell :: new ( None ) ,
571
+ id,
595
572
} ;
596
573
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) ;
598
575
}
599
576
ast:: UseTreeKind :: Nested ( ref items) => {
600
577
// Ensure there is at most one `self` in the list
@@ -881,9 +858,8 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
881
858
} )
882
859
. unwrap_or ( ( true , None , self . r . dummy_binding ) ) ;
883
860
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 } ,
885
862
root_id : item. id ,
886
- id : item. id ,
887
863
parent_scope : self . parent_scope ,
888
864
imported_module : Cell :: new ( module) ,
889
865
has_attributes : !item. attrs . is_empty ( ) ,
@@ -1118,7 +1094,6 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
1118
1094
this. r . arenas . alloc_import ( Import {
1119
1095
kind : ImportKind :: MacroUse ,
1120
1096
root_id : item. id ,
1121
- id : item. id ,
1122
1097
parent_scope : this. parent_scope ,
1123
1098
imported_module : Cell :: new ( Some ( ModuleOrUniformRoot :: Module ( module) ) ) ,
1124
1099
use_span_with_attributes : item. span_with_attributes ( ) ,
@@ -1278,8 +1253,22 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
1278
1253
let binding = ( res, vis, span, expansion) . to_name_binding ( self . r . arenas ) ;
1279
1254
self . r . set_binding_parent_module ( binding, parent_scope. module ) ;
1280
1255
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) ;
1283
1272
} else {
1284
1273
self . r . check_reserved_macro_name ( ident, res) ;
1285
1274
self . insert_unused_macro ( ident, def_id, item. id , & rule_spans) ;
0 commit comments