@@ -58,17 +58,19 @@ macro_rules! down_cast_data {
5858}
5959
6060macro_rules! access_from {
61- ( $save_ctxt: expr, $vis : expr, $id: expr) => {
61+ ( $save_ctxt: expr, $item : expr, $id: expr) => {
6262 Access {
63- public: $vis. node. is_pub( ) ,
63+ public: $item . vis. node. is_pub( ) ,
6464 reachable: $save_ctxt. access_levels. is_reachable( $id) ,
6565 }
6666 } ;
67+ }
6768
68- ( $save_ctxt: expr, $item: expr) => {
69+ macro_rules! access_from_vis {
70+ ( $save_ctxt: expr, $vis: expr, $id: expr) => {
6971 Access {
70- public: $item . vis. node. is_pub( ) ,
71- reachable: $save_ctxt. access_levels. is_reachable( $item . id) ,
72+ public: $vis. node. is_pub( ) ,
73+ reachable: $save_ctxt. access_levels. is_reachable( $id) ,
7274 }
7375 } ;
7476}
@@ -303,7 +305,8 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
303305
304306 method_data. value = sig_str;
305307 method_data. sig = sig:: method_signature ( id, ident, generics, sig, & self . save_ctxt ) ;
306- self . dumper . dump_def ( & access_from ! ( self . save_ctxt, vis, id) , method_data) ;
308+ let hir_id = self . tcx . hir ( ) . node_to_hir_id ( id) ;
309+ self . dumper . dump_def ( & access_from_vis ! ( self . save_ctxt, vis, hir_id) , method_data) ;
307310 }
308311
309312 // walk arg and return types
@@ -324,7 +327,8 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
324327 fn process_struct_field_def ( & mut self , field : & ast:: StructField , parent_id : NodeId ) {
325328 let field_data = self . save_ctxt . get_field_data ( field, parent_id) ;
326329 if let Some ( field_data) = field_data {
327- self . dumper . dump_def ( & access_from ! ( self . save_ctxt, field) , field_data) ;
330+ let hir_id = self . tcx . hir ( ) . node_to_hir_id ( field. id ) ;
331+ self . dumper . dump_def ( & access_from ! ( self . save_ctxt, field, hir_id) , field_data) ;
328332 }
329333 }
330334
@@ -389,7 +393,8 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
389393 |v| v. process_formals ( & decl. inputs , & fn_data. qualname ) ,
390394 ) ;
391395 self . process_generic_params ( ty_params, & fn_data. qualname , item. id ) ;
392- self . dumper . dump_def ( & access_from ! ( self . save_ctxt, item) , fn_data) ;
396+ let hir_id = self . tcx . hir ( ) . node_to_hir_id ( item. id ) ;
397+ self . dumper . dump_def ( & access_from ! ( self . save_ctxt, item, hir_id) , fn_data) ;
393398 }
394399
395400 for arg in & decl. inputs {
@@ -409,10 +414,11 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
409414 typ : & ' l ast:: Ty ,
410415 expr : & ' l ast:: Expr ,
411416 ) {
417+ let hir_id = self . tcx . hir ( ) . node_to_hir_id ( item. id ) ;
412418 self . nest_tables ( item. id , |v| {
413419 if let Some ( var_data) = v. save_ctxt . get_item_data ( item) {
414420 down_cast_data ! ( var_data, DefData , item. span) ;
415- v. dumper . dump_def ( & access_from ! ( v. save_ctxt, item) , var_data) ;
421+ v. dumper . dump_def ( & access_from ! ( v. save_ctxt, item, hir_id ) , var_data) ;
416422 }
417423 v. visit_ty ( & typ) ;
418424 v. visit_expr ( expr) ;
@@ -434,9 +440,10 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
434440 if !self . span . filter_generated ( ident. span ) {
435441 let sig = sig:: assoc_const_signature ( id, ident. name , typ, expr, & self . save_ctxt ) ;
436442 let span = self . span_from_span ( ident. span ) ;
443+ let hir_id = self . tcx . hir ( ) . node_to_hir_id ( id) ;
437444
438445 self . dumper . dump_def (
439- & access_from ! ( self . save_ctxt, vis, id ) ,
446+ & access_from_vis ! ( self . save_ctxt, vis, hir_id ) ,
440447 Def {
441448 kind : DefKind :: Const ,
442449 id : id_from_node_id ( id, & self . save_ctxt ) ,
@@ -510,8 +517,9 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
510517
511518 if !self . span . filter_generated ( item. ident . span ) {
512519 let span = self . span_from_span ( item. ident . span ) ;
520+ let hir_id = self . tcx . hir ( ) . node_to_hir_id ( item. id ) ;
513521 self . dumper . dump_def (
514- & access_from ! ( self . save_ctxt, item) ,
522+ & access_from ! ( self . save_ctxt, item, hir_id ) ,
515523 Def {
516524 kind,
517525 id : id_from_node_id ( item. id , & self . save_ctxt ) ,
@@ -550,7 +558,8 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
550558 } ;
551559 down_cast_data ! ( enum_data, DefData , item. span) ;
552560
553- let access = access_from ! ( self . save_ctxt, item) ;
561+ let hir_id = self . tcx . hir ( ) . node_to_hir_id ( item. id ) ;
562+ let access = access_from ! ( self . save_ctxt, item, hir_id) ;
554563
555564 for variant in & enum_definition. variants {
556565 let name = variant. node . ident . name . to_string ( ) ;
@@ -698,8 +707,9 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
698707 . iter ( )
699708 . map ( |i| id_from_node_id ( i. id , & self . save_ctxt ) )
700709 . collect ( ) ;
710+ let hir_id = self . tcx . hir ( ) . node_to_hir_id ( item. id ) ;
701711 self . dumper . dump_def (
702- & access_from ! ( self . save_ctxt, item) ,
712+ & access_from ! ( self . save_ctxt, item, hir_id ) ,
703713 Def {
704714 kind : DefKind :: Trait ,
705715 id,
@@ -757,7 +767,8 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
757767 fn process_mod ( & mut self , item : & ast:: Item ) {
758768 if let Some ( mod_data) = self . save_ctxt . get_item_data ( item) {
759769 down_cast_data ! ( mod_data, DefData , item. span) ;
760- self . dumper . dump_def ( & access_from ! ( self . save_ctxt, item) , mod_data) ;
770+ let hir_id = self . tcx . hir ( ) . node_to_hir_id ( item. id ) ;
771+ self . dumper . dump_def ( & access_from ! ( self . save_ctxt, item, hir_id) , mod_data) ;
761772 }
762773 }
763774
@@ -1197,7 +1208,8 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
11971208
11981209 // The access is calculated using the current tree ID, but with the root tree's visibility
11991210 // (since nested trees don't have their own visibility).
1200- let access = access_from ! ( self . save_ctxt, root_item. vis, id) ;
1211+ let hir_id = self . tcx . hir ( ) . node_to_hir_id ( id) ;
1212+ let access = access_from ! ( self . save_ctxt, root_item, hir_id) ;
12011213
12021214 // The parent def id of a given use tree is always the enclosing item.
12031215 let parent = self . save_ctxt . tcx . hir ( ) . opt_local_def_id ( id)
@@ -1394,9 +1406,10 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> Visitor<'l> for DumpVisitor<'l, 'tc
13941406 if !self . span . filter_generated ( item. ident . span ) {
13951407 let span = self . span_from_span ( item. ident . span ) ;
13961408 let id = id_from_node_id ( item. id , & self . save_ctxt ) ;
1409+ let hir_id = self . tcx . hir ( ) . node_to_hir_id ( item. id ) ;
13971410
13981411 self . dumper . dump_def (
1399- & access_from ! ( self . save_ctxt, item) ,
1412+ & access_from ! ( self . save_ctxt, item, hir_id ) ,
14001413 Def {
14011414 kind : DefKind :: Type ,
14021415 id,
@@ -1424,9 +1437,10 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> Visitor<'l> for DumpVisitor<'l, 'tc
14241437 if !self . span . filter_generated ( item. ident . span ) {
14251438 let span = self . span_from_span ( item. ident . span ) ;
14261439 let id = id_from_node_id ( item. id , & self . save_ctxt ) ;
1440+ let hir_id = self . tcx . hir ( ) . node_to_hir_id ( item. id ) ;
14271441
14281442 self . dumper . dump_def (
1429- & access_from ! ( self . save_ctxt, item) ,
1443+ & access_from ! ( self . save_ctxt, item, hir_id ) ,
14301444 Def {
14311445 kind : DefKind :: Type ,
14321446 id,
@@ -1624,7 +1638,8 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> Visitor<'l> for DumpVisitor<'l, 'tc
16241638 }
16251639
16261640 fn visit_foreign_item ( & mut self , item : & ' l ast:: ForeignItem ) {
1627- let access = access_from ! ( self . save_ctxt, item) ;
1641+ let hir_id = self . tcx . hir ( ) . node_to_hir_id ( item. id ) ;
1642+ let access = access_from ! ( self . save_ctxt, item, hir_id) ;
16281643
16291644 match item. node {
16301645 ast:: ForeignItemKind :: Fn ( ref decl, ref generics) => {
0 commit comments