@@ -57,9 +57,9 @@ macro_rules! down_cast_data {
5757}
5858
5959macro_rules! access_from {
60- ( $save_ctxt: expr, $item : expr , $ id: expr) => {
60+ ( $save_ctxt: expr, $id: expr) => {
6161 Access {
62- public: $item . vis . node . is_pub ( ) ,
62+ public: $save_ctxt . tcx . visibility ( $id ) . is_public ( ) ,
6363 reachable: $save_ctxt. access_levels. is_reachable( $id) ,
6464 }
6565 } ;
@@ -302,7 +302,7 @@ impl<'tcx> DumpVisitor<'tcx> {
302302 let field_data = self . save_ctxt . get_field_data ( field, parent_id) ;
303303 if let Some ( field_data) = field_data {
304304 self . dumper . dump_def (
305- & access_from ! ( self . save_ctxt, field , self . tcx. hir( ) . local_def_id( field. hir_id) ) ,
305+ & access_from ! ( self . save_ctxt, self . tcx. hir( ) . local_def_id( field. hir_id) ) ,
306306 field_data,
307307 ) ;
308308 }
@@ -369,7 +369,7 @@ impl<'tcx> DumpVisitor<'tcx> {
369369 v. process_formals ( body. params , & fn_data. qualname ) ;
370370 v. process_generic_params ( ty_params, & fn_data. qualname , item. hir_id ( ) ) ;
371371
372- v. dumper . dump_def ( & access_from ! ( v. save_ctxt, item, item . def_id) , fn_data) ;
372+ v. dumper . dump_def ( & access_from ! ( v. save_ctxt, item. def_id) , fn_data) ;
373373 }
374374
375375 for arg in decl. inputs {
@@ -393,7 +393,7 @@ impl<'tcx> DumpVisitor<'tcx> {
393393 self . nest_typeck_results ( item. def_id , |v| {
394394 if let Some ( var_data) = v. save_ctxt . get_item_data ( item) {
395395 down_cast_data ! ( var_data, DefData , item. span) ;
396- v. dumper . dump_def ( & access_from ! ( v. save_ctxt, item, item . def_id) , var_data) ;
396+ v. dumper . dump_def ( & access_from ! ( v. save_ctxt, item. def_id) , var_data) ;
397397 }
398398 v. visit_ty ( & typ) ;
399399 v. visit_expr ( expr) ;
@@ -469,7 +469,11 @@ impl<'tcx> DumpVisitor<'tcx> {
469469 let fields_str = fields
470470 . iter ( )
471471 . filter_map ( |f| {
472- if include_priv_fields || f. vis . node . is_pub ( ) {
472+ if include_priv_fields {
473+ return Some ( f. ident . to_string ( ) ) ;
474+ }
475+ let def_id = self . save_ctxt . tcx . hir ( ) . local_def_id ( f. hir_id ) ;
476+ if self . save_ctxt . tcx . visibility ( def_id) . is_public ( ) {
473477 Some ( f. ident . to_string ( ) )
474478 } else {
475479 None
@@ -487,7 +491,7 @@ impl<'tcx> DumpVisitor<'tcx> {
487491 let span = self . span_from_span ( item. ident . span ) ;
488492 let attrs = self . tcx . hir ( ) . attrs ( item. hir_id ( ) ) ;
489493 self . dumper . dump_def (
490- & access_from ! ( self . save_ctxt, item, item . def_id) ,
494+ & access_from ! ( self . save_ctxt, item. def_id) ,
491495 Def {
492496 kind,
493497 id : id_from_def_id ( item. def_id . to_def_id ( ) ) ,
@@ -527,7 +531,7 @@ impl<'tcx> DumpVisitor<'tcx> {
527531 } ;
528532 down_cast_data ! ( enum_data, DefData , item. span) ;
529533
530- let access = access_from ! ( self . save_ctxt, item, item . def_id) ;
534+ let access = access_from ! ( self . save_ctxt, item. def_id) ;
531535
532536 for variant in enum_definition. variants {
533537 let name = variant. ident . name . to_string ( ) ;
@@ -662,7 +666,7 @@ impl<'tcx> DumpVisitor<'tcx> {
662666 methods. iter ( ) . map ( |i| id_from_def_id ( i. id . def_id . to_def_id ( ) ) ) . collect ( ) ;
663667 let attrs = self . tcx . hir ( ) . attrs ( item. hir_id ( ) ) ;
664668 self . dumper . dump_def (
665- & access_from ! ( self . save_ctxt, item, item . def_id) ,
669+ & access_from ! ( self . save_ctxt, item. def_id) ,
666670 Def {
667671 kind : DefKind :: Trait ,
668672 id,
@@ -724,7 +728,7 @@ impl<'tcx> DumpVisitor<'tcx> {
724728 fn process_mod ( & mut self , item : & ' tcx hir:: Item < ' tcx > ) {
725729 if let Some ( mod_data) = self . save_ctxt . get_item_data ( item) {
726730 down_cast_data ! ( mod_data, DefData , item. span) ;
727- self . dumper . dump_def ( & access_from ! ( self . save_ctxt, item, item . def_id) , mod_data) ;
731+ self . dumper . dump_def ( & access_from ! ( self . save_ctxt, item. def_id) , mod_data) ;
728732 }
729733 }
730734
@@ -1147,7 +1151,7 @@ impl<'tcx> Visitor<'tcx> for DumpVisitor<'tcx> {
11471151 hir:: ItemKind :: Use ( path, hir:: UseKind :: Single ) => {
11481152 let sub_span = path. segments . last ( ) . unwrap ( ) . ident . span ;
11491153 if !self . span . filter_generated ( sub_span) {
1150- let access = access_from ! ( self . save_ctxt, item, item . def_id) ;
1154+ let access = access_from ! ( self . save_ctxt, item. def_id) ;
11511155 let ref_id = self . lookup_def_id ( item. hir_id ( ) ) . map ( id_from_def_id) ;
11521156 let span = self . span_from_span ( sub_span) ;
11531157 let parent =
@@ -1176,7 +1180,7 @@ impl<'tcx> Visitor<'tcx> for DumpVisitor<'tcx> {
11761180 // we don't want to track anyway, since it's probably macro-internal `use`
11771181 if let Some ( sub_span) = self . span . sub_span_of_star ( item. span ) {
11781182 if !self . span . filter_generated ( item. span ) {
1179- let access = access_from ! ( self . save_ctxt, item, item . def_id) ;
1183+ let access = access_from ! ( self . save_ctxt, item. def_id) ;
11801184 let span = self . span_from_span ( sub_span) ;
11811185 let parent =
11821186 self . save_ctxt . tcx . parent ( item. def_id . to_def_id ( ) ) . map ( id_from_def_id) ;
@@ -1249,7 +1253,7 @@ impl<'tcx> Visitor<'tcx> for DumpVisitor<'tcx> {
12491253 let attrs = self . tcx . hir ( ) . attrs ( item. hir_id ( ) ) ;
12501254
12511255 self . dumper . dump_def (
1252- & access_from ! ( self . save_ctxt, item, item . def_id) ,
1256+ & access_from ! ( self . save_ctxt, item. def_id) ,
12531257 Def {
12541258 kind : DefKind :: Type ,
12551259 id,
@@ -1443,7 +1447,7 @@ impl<'tcx> Visitor<'tcx> for DumpVisitor<'tcx> {
14431447 }
14441448
14451449 fn visit_foreign_item ( & mut self , item : & ' tcx hir:: ForeignItem < ' tcx > ) {
1446- let access = access_from ! ( self . save_ctxt, item, item . def_id) ;
1450+ let access = access_from ! ( self . save_ctxt, item. def_id) ;
14471451
14481452 match item. kind {
14491453 hir:: ForeignItemKind :: Fn ( decl, _, ref generics) => {
0 commit comments