@@ -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) ;
@@ -435,9 +441,10 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
435441 if !self . span . filter_generated ( ident. span ) {
436442 let sig = sig:: assoc_const_signature ( id, ident. name , typ, expr, & self . save_ctxt ) ;
437443 let span = self . span_from_span ( ident. span ) ;
444+ let hir_id = self . tcx . hir ( ) . node_to_hir_id ( id) ;
438445
439446 self . dumper . dump_def (
440- & access_from ! ( self . save_ctxt, vis, id ) ,
447+ & access_from_vis ! ( self . save_ctxt, vis, hir_id ) ,
441448 Def {
442449 kind : DefKind :: Const ,
443450 id : id_from_node_id ( id, & self . save_ctxt ) ,
@@ -512,8 +519,9 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
512519
513520 if !self . span . filter_generated ( item. ident . span ) {
514521 let span = self . span_from_span ( item. ident . span ) ;
522+ let hir_id = self . tcx . hir ( ) . node_to_hir_id ( item. id ) ;
515523 self . dumper . dump_def (
516- & access_from ! ( self . save_ctxt, item) ,
524+ & access_from ! ( self . save_ctxt, item, hir_id ) ,
517525 Def {
518526 kind,
519527 id : id_from_node_id ( item. id , & self . save_ctxt ) ,
@@ -552,7 +560,8 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
552560 } ;
553561 down_cast_data ! ( enum_data, DefData , item. span) ;
554562
555- let access = access_from ! ( self . save_ctxt, item) ;
563+ let hir_id = self . tcx . hir ( ) . node_to_hir_id ( item. id ) ;
564+ let access = access_from ! ( self . save_ctxt, item, hir_id) ;
556565
557566 for variant in & enum_definition. variants {
558567 let name = variant. node . ident . name . to_string ( ) ;
@@ -701,8 +710,9 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
701710 . iter ( )
702711 . map ( |i| id_from_node_id ( i. id , & self . save_ctxt ) )
703712 . collect ( ) ;
713+ let hir_id = self . tcx . hir ( ) . node_to_hir_id ( item. id ) ;
704714 self . dumper . dump_def (
705- & access_from ! ( self . save_ctxt, item) ,
715+ & access_from ! ( self . save_ctxt, item, hir_id ) ,
706716 Def {
707717 kind : DefKind :: Trait ,
708718 id,
@@ -760,7 +770,8 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
760770 fn process_mod ( & mut self , item : & ast:: Item ) {
761771 if let Some ( mod_data) = self . save_ctxt . get_item_data ( item) {
762772 down_cast_data ! ( mod_data, DefData , item. span) ;
763- self . dumper . dump_def ( & access_from ! ( self . save_ctxt, item) , mod_data) ;
773+ let hir_id = self . tcx . hir ( ) . node_to_hir_id ( item. id ) ;
774+ self . dumper . dump_def ( & access_from ! ( self . save_ctxt, item, hir_id) , mod_data) ;
764775 }
765776 }
766777
@@ -1201,7 +1212,8 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
12011212
12021213 // The access is calculated using the current tree ID, but with the root tree's visibility
12031214 // (since nested trees don't have their own visibility).
1204- let access = access_from ! ( self . save_ctxt, root_item. vis, id) ;
1215+ let hir_id = self . tcx . hir ( ) . node_to_hir_id ( id) ;
1216+ let access = access_from ! ( self . save_ctxt, root_item, hir_id) ;
12051217
12061218 // The parent def id of a given use tree is always the enclosing item.
12071219 let parent = self . save_ctxt . tcx . hir ( ) . opt_local_def_id ( id)
@@ -1400,9 +1412,10 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> Visitor<'l> for DumpVisitor<'l, 'tc
14001412 if !self . span . filter_generated ( item. ident . span ) {
14011413 let span = self . span_from_span ( item. ident . span ) ;
14021414 let id = id_from_node_id ( item. id , & self . save_ctxt ) ;
1415+ let hir_id = self . tcx . hir ( ) . node_to_hir_id ( item. id ) ;
14031416
14041417 self . dumper . dump_def (
1405- & access_from ! ( self . save_ctxt, item) ,
1418+ & access_from ! ( self . save_ctxt, item, hir_id ) ,
14061419 Def {
14071420 kind : DefKind :: Type ,
14081421 id,
@@ -1431,9 +1444,10 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> Visitor<'l> for DumpVisitor<'l, 'tc
14311444 if !self . span . filter_generated ( item. ident . span ) {
14321445 let span = self . span_from_span ( item. ident . span ) ;
14331446 let id = id_from_node_id ( item. id , & self . save_ctxt ) ;
1447+ let hir_id = self . tcx . hir ( ) . node_to_hir_id ( item. id ) ;
14341448
14351449 self . dumper . dump_def (
1436- & access_from ! ( self . save_ctxt, item) ,
1450+ & access_from ! ( self . save_ctxt, item, hir_id ) ,
14371451 Def {
14381452 kind : DefKind :: Type ,
14391453 id,
@@ -1631,7 +1645,8 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> Visitor<'l> for DumpVisitor<'l, 'tc
16311645 }
16321646
16331647 fn visit_foreign_item ( & mut self , item : & ' l ast:: ForeignItem ) {
1634- let access = access_from ! ( self . save_ctxt, item) ;
1648+ let hir_id = self . tcx . hir ( ) . node_to_hir_id ( item. id ) ;
1649+ let access = access_from ! ( self . save_ctxt, item, hir_id) ;
16351650
16361651 match item. node {
16371652 ast:: ForeignItemKind :: Fn ( ref decl, ref generics) => {
0 commit comments