@@ -29,12 +29,13 @@ use syntax::feature_gate::UnstableFeatures;
2929use syntax:: parse:: token;
3030
3131use std:: cell:: { RefCell , Cell } ;
32- use std:: collections:: { HashMap , HashSet } ;
32+ use std:: collections:: HashMap ;
3333use std:: rc:: Rc ;
3434
3535use visit_ast:: RustdocVisitor ;
3636use clean;
3737use clean:: Clean ;
38+ use html:: render:: RenderInfo ;
3839
3940pub use rustc:: session:: config:: Input ;
4041pub use rustc:: session:: search_paths:: SearchPaths ;
@@ -45,19 +46,24 @@ pub enum MaybeTyped<'a, 'tcx: 'a> {
4546 NotTyped ( & ' a session:: Session )
4647}
4748
48- pub type ExternalPaths = RefCell < Option < HashMap < DefId ,
49- ( Vec < String > , clean:: TypeKind ) > > > ;
49+ pub type Externs = HashMap < String , Vec < String > > ;
50+ pub type ExternalPaths = HashMap < DefId , ( Vec < String > , clean:: TypeKind ) > ;
5051
5152pub struct DocContext < ' a , ' tcx : ' a > {
5253 pub map : & ' a hir_map:: Map < ' tcx > ,
5354 pub maybe_typed : MaybeTyped < ' a , ' tcx > ,
5455 pub input : Input ,
55- pub external_paths : ExternalPaths ,
56- pub external_traits : RefCell < Option < HashMap < DefId , clean:: Trait > > > ,
57- pub external_typarams : RefCell < Option < HashMap < DefId , String > > > ,
58- pub inlined : RefCell < Option < HashSet < DefId > > > ,
5956 pub all_crate_impls : RefCell < HashMap < ast:: CrateNum , Vec < clean:: Item > > > ,
6057 pub deref_trait_did : Cell < Option < DefId > > ,
58+ // Note that external items for which `doc(hidden)` applies to are shown as
59+ // non-reachable while local items aren't. This is because we're reusing
60+ // the access levels from crateanalysis.
61+ /// Later on moved into `clean::Crate`
62+ pub access_levels : RefCell < AccessLevels < DefId > > ,
63+ /// Later on moved into `html::render::CACHE_KEY`
64+ pub renderinfo : RefCell < RenderInfo > ,
65+ /// Later on moved through `clean::Crate` into `html::render::CACHE_KEY`
66+ pub external_traits : RefCell < HashMap < DefId , clean:: Trait > > ,
6167}
6268
6369impl < ' b , ' tcx > DocContext < ' b , ' tcx > {
@@ -81,20 +87,23 @@ impl<'b, 'tcx> DocContext<'b, 'tcx> {
8187 }
8288}
8389
84- pub struct CrateAnalysis {
85- pub access_levels : AccessLevels < DefId > ,
86- pub external_paths : ExternalPaths ,
87- pub external_typarams : RefCell < Option < HashMap < DefId , String > > > ,
88- pub inlined : RefCell < Option < HashSet < DefId > > > ,
89- pub deref_trait_did : Option < DefId > ,
90+ pub trait DocAccessLevels {
91+ fn is_doc_reachable ( & self , DefId ) -> bool ;
9092}
9193
92- pub type Externs = HashMap < String , Vec < String > > ;
94+ impl DocAccessLevels for AccessLevels < DefId > {
95+ fn is_doc_reachable ( & self , did : DefId ) -> bool {
96+ self . is_public ( did)
97+ }
98+ }
9399
94- pub fn run_core ( search_paths : SearchPaths , cfgs : Vec < String > , externs : Externs ,
95- input : Input , triple : Option < String > )
96- -> ( clean:: Crate , CrateAnalysis ) {
97100
101+ pub fn run_core ( search_paths : SearchPaths ,
102+ cfgs : Vec < String > ,
103+ externs : Externs ,
104+ input : Input ,
105+ triple : Option < String > ) -> ( clean:: Crate , RenderInfo )
106+ {
98107 // Parse, resolve, and typecheck the given crate.
99108
100109 let cpath = match input {
@@ -148,7 +157,7 @@ pub fn run_core(search_paths: SearchPaths, cfgs: Vec<String>, externs: Externs,
148157 let arenas = ty:: CtxtArenas :: new ( ) ;
149158 let hir_map = driver:: make_map ( & sess, & mut hir_forest) ;
150159
151- let krate_and_analysis = abort_on_err ( driver:: phase_3_run_analysis_passes ( & sess,
160+ abort_on_err ( driver:: phase_3_run_analysis_passes ( & sess,
152161 & cstore,
153162 hir_map,
154163 & arenas,
@@ -175,42 +184,20 @@ pub fn run_core(search_paths: SearchPaths, cfgs: Vec<String>, externs: Externs,
175184 map : & tcx. map ,
176185 maybe_typed : Typed ( tcx) ,
177186 input : input,
178- external_traits : RefCell :: new ( Some ( HashMap :: new ( ) ) ) ,
179- external_typarams : RefCell :: new ( Some ( HashMap :: new ( ) ) ) ,
180- external_paths : RefCell :: new ( Some ( HashMap :: new ( ) ) ) ,
181- inlined : RefCell :: new ( Some ( HashSet :: new ( ) ) ) ,
182187 all_crate_impls : RefCell :: new ( HashMap :: new ( ) ) ,
183188 deref_trait_did : Cell :: new ( None ) ,
189+ access_levels : RefCell :: new ( access_levels) ,
190+ external_traits : RefCell :: new ( HashMap :: new ( ) ) ,
191+ renderinfo : RefCell :: new ( Default :: default ( ) ) ,
184192 } ;
185193 debug ! ( "crate: {:?}" , ctxt. map. krate( ) ) ;
186194
187- let mut analysis = CrateAnalysis {
188- access_levels : access_levels,
189- external_paths : RefCell :: new ( None ) ,
190- external_typarams : RefCell :: new ( None ) ,
191- inlined : RefCell :: new ( None ) ,
192- deref_trait_did : None ,
193- } ;
194-
195195 let krate = {
196- let mut v = RustdocVisitor :: new ( & ctxt, Some ( & analysis ) ) ;
196+ let mut v = RustdocVisitor :: new ( & ctxt) ;
197197 v. visit ( ctxt. map . krate ( ) ) ;
198198 v. clean ( & ctxt)
199199 } ;
200200
201- let external_paths = ctxt. external_paths . borrow_mut ( ) . take ( ) ;
202- * analysis. external_paths . borrow_mut ( ) = external_paths;
203-
204- let map = ctxt. external_typarams . borrow_mut ( ) . take ( ) ;
205- * analysis. external_typarams . borrow_mut ( ) = map;
206-
207- let map = ctxt. inlined . borrow_mut ( ) . take ( ) ;
208- * analysis. inlined . borrow_mut ( ) = map;
209-
210- analysis. deref_trait_did = ctxt. deref_trait_did . get ( ) ;
211-
212- Some ( ( krate, analysis) )
213- } ) , & sess) ;
214-
215- krate_and_analysis. unwrap ( )
201+ Some ( ( krate, ctxt. renderinfo . into_inner ( ) ) )
202+ } ) , & sess) . unwrap ( )
216203}
0 commit comments