@@ -10,7 +10,6 @@ use rustc_hir::CRATE_HIR_ID;
1010use rustc_middle:: middle:: privacy:: AccessLevel ;
1111use rustc_middle:: ty:: TyCtxt ;
1212use rustc_span:: def_id:: { CRATE_DEF_ID , LOCAL_CRATE } ;
13- use rustc_span:: source_map:: Spanned ;
1413use rustc_span:: symbol:: { kw, sym, Symbol } ;
1514
1615use std:: mem;
@@ -72,9 +71,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
7271 }
7372
7473 crate fn visit ( mut self ) -> Module < ' tcx > {
75- let span = self . cx . tcx . def_span ( CRATE_DEF_ID ) ;
7674 let mut top_level_module = self . visit_mod_contents (
77- & Spanned { span, node : hir:: VisibilityKind :: Public } ,
7875 hir:: CRATE_HIR_ID ,
7976 self . cx . tcx . hir ( ) . root_module ( ) ,
8077 self . cx . tcx . crate_name ( LOCAL_CRATE ) ,
@@ -134,15 +131,15 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
134131
135132 fn visit_mod_contents (
136133 & mut self ,
137- vis : & hir:: Visibility < ' _ > ,
138134 id : hir:: HirId ,
139135 m : & ' tcx hir:: Mod < ' tcx > ,
140136 name : Symbol ,
141137 ) -> Module < ' tcx > {
142138 let mut om = Module :: new ( name, id, m. inner ) ;
139+ let def_id = self . cx . tcx . hir ( ) . local_def_id ( id) . to_def_id ( ) ;
143140 // Keep track of if there were any private modules in the path.
144141 let orig_inside_public_path = self . inside_public_path ;
145- self . inside_public_path &= vis . node . is_pub ( ) ;
142+ self . inside_public_path &= self . cx . tcx . visibility ( def_id ) . is_public ( ) ;
146143 for & i in m. item_ids {
147144 let item = self . cx . tcx . hir ( ) . item ( i) ;
148145 self . visit_item ( item, None , & mut om) ;
@@ -259,7 +256,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
259256 let name = renamed. unwrap_or ( item. ident . name ) ;
260257
261258 let def_id = item. def_id . to_def_id ( ) ;
262- let is_pub = item . vis . node . is_pub ( ) || self . cx . tcx . has_attr ( def_id, sym :: macro_export ) ;
259+ let is_pub = self . cx . tcx . visibility ( def_id) . is_public ( ) ;
263260
264261 if is_pub {
265262 self . store_path ( item. def_id . to_def_id ( ) ) ;
@@ -332,7 +329,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
332329 }
333330 }
334331 hir:: ItemKind :: Mod ( ref m) => {
335- om. mods . push ( self . visit_mod_contents ( & item . vis , item. hir_id ( ) , m, name) ) ;
332+ om. mods . push ( self . visit_mod_contents ( item. hir_id ( ) , m, name) ) ;
336333 }
337334 hir:: ItemKind :: Fn ( ..)
338335 | hir:: ItemKind :: ExternCrate ( ..)
@@ -368,7 +365,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
368365 om : & mut Module < ' tcx > ,
369366 ) {
370367 // If inlining we only want to include public functions.
371- if !self . inlining || item . vis . node . is_pub ( ) {
368+ if !self . inlining || self . cx . tcx . visibility ( item . def_id ) . is_public ( ) {
372369 om. foreigns . push ( ( item, renamed) ) ;
373370 }
374371 }
0 commit comments