11use rustc:: middle:: privacy:: { AccessLevels , AccessLevel } ;
22use rustc:: hir:: def:: { Res , DefKind } ;
33use rustc:: hir:: def_id:: { CrateNum , CRATE_DEF_INDEX , DefId } ;
4- use rustc:: ty:: Visibility ;
4+ use rustc:: ty:: { TyCtxt , Visibility } ;
55use rustc:: util:: nodemap:: FxHashSet ;
66use syntax:: symbol:: sym;
77
8- use std:: cell:: RefMut ;
9-
108use crate :: clean:: { AttributesExt , NestedAttributesExt } ;
119
1210// FIXME: this may not be exhaustive, but is sufficient for rustdocs current uses
1311
1412/// Similar to `librustc_privacy::EmbargoVisitor`, but also takes
1513/// specific rustdoc annotations into account (i.e., `doc(hidden)`)
1614pub struct LibEmbargoVisitor < ' a , ' tcx > {
17- cx : & ' a crate :: core :: DocContext < ' tcx > ,
15+ tcx : TyCtxt < ' tcx > ,
1816 // Accessibility levels for reachable nodes
19- access_levels : RefMut < ' a , AccessLevels < DefId > > ,
17+ access_levels : & ' a mut AccessLevels < DefId > ,
2018 // Previous accessibility level, None means unreachable
2119 prev_level : Option < AccessLevel > ,
2220 // Keeps track of already visited modules, in case a module re-exports its parent
@@ -25,13 +23,13 @@ pub struct LibEmbargoVisitor<'a, 'tcx> {
2523
2624impl < ' a , ' tcx > LibEmbargoVisitor < ' a , ' tcx > {
2725 pub fn new (
28- cx : & ' a crate :: core:: DocContext < ' tcx >
26+ cx : & ' a mut crate :: core:: DocContext < ' tcx >
2927 ) -> LibEmbargoVisitor < ' a , ' tcx > {
3028 LibEmbargoVisitor {
31- cx ,
32- access_levels : RefMut :: map ( cx. renderinfo . borrow_mut ( ) , |ri| & mut ri . access_levels ) ,
29+ tcx : cx . tcx ,
30+ access_levels : & mut cx. renderinfo . get_mut ( ) . access_levels ,
3331 prev_level : Some ( AccessLevel :: Public ) ,
34- visited_mods : FxHashSet :: default ( )
32+ visited_mods : FxHashSet :: default ( ) ,
3533 }
3634 }
3735
@@ -43,7 +41,7 @@ impl<'a, 'tcx> LibEmbargoVisitor<'a, 'tcx> {
4341
4442 // Updates node level and returns the updated level
4543 fn update ( & mut self , did : DefId , level : Option < AccessLevel > ) -> Option < AccessLevel > {
46- let is_hidden = self . cx . tcx . get_attrs ( did) . lists ( sym:: doc) . has_word ( sym:: hidden) ;
44+ let is_hidden = self . tcx . get_attrs ( did) . lists ( sym:: doc) . has_word ( sym:: hidden) ;
4745
4846 let old_level = self . access_levels . map . get ( & did) . cloned ( ) ;
4947 // Accessibility levels can only grow
@@ -60,9 +58,9 @@ impl<'a, 'tcx> LibEmbargoVisitor<'a, 'tcx> {
6058 return ;
6159 }
6260
63- for item in self . cx . tcx . item_children ( def_id) . iter ( ) {
61+ for item in self . tcx . item_children ( def_id) . iter ( ) {
6462 if let Some ( def_id) = item. res . opt_def_id ( ) {
65- if self . cx . tcx . def_key ( def_id) . parent . map_or ( false , |d| d == def_id. index ) ||
63+ if self . tcx . def_key ( def_id) . parent . map_or ( false , |d| d == def_id. index ) ||
6664 item. vis == Visibility :: Public {
6765 self . visit_item ( item. res ) ;
6866 }
@@ -72,7 +70,7 @@ impl<'a, 'tcx> LibEmbargoVisitor<'a, 'tcx> {
7270
7371 fn visit_item ( & mut self , res : Res ) {
7472 let def_id = res. def_id ( ) ;
75- let vis = self . cx . tcx . visibility ( def_id) ;
73+ let vis = self . tcx . visibility ( def_id) ;
7674 let inherited_item_level = if vis == Visibility :: Public {
7775 self . prev_level
7876 } else {
0 commit comments