@@ -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,20 @@ 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 ExternalPaths = HashMap < DefId , ( Vec < String > , clean:: TypeKind ) > ;
5050
5151pub struct DocContext < ' a , ' tcx : ' a > {
5252 pub map : & ' a hir_map:: Map < ' tcx > ,
5353 pub maybe_typed : MaybeTyped < ' a , ' tcx > ,
5454 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 > > > ,
5955 pub all_crate_impls : RefCell < HashMap < ast:: CrateNum , Vec < clean:: Item > > > ,
56+ // Later on moved into `clean::Crate`
57+ pub access_levels : RefCell < AccessLevels < DefId > > ,
58+ // Later on moved into `html::render::CACHE_KEY`
59+ pub renderinfo : RefCell < RenderInfo > ,
6060 pub deref_trait_did : Cell < Option < DefId > > ,
61+ // Later on moved through `clean::Crate` into `html::render::CACHE_KEY`
62+ pub external_traits : RefCell < HashMap < DefId , clean:: Trait > > ,
6163}
6264
6365impl < ' b , ' tcx > DocContext < ' b , ' tcx > {
@@ -81,20 +83,14 @@ impl<'b, 'tcx> DocContext<'b, 'tcx> {
8183 }
8284}
8385
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- }
91-
9286pub type Externs = HashMap < String , Vec < String > > ;
9387
94- pub fn run_core ( search_paths : SearchPaths , cfgs : Vec < String > , externs : Externs ,
95- input : Input , triple : Option < String > )
96- -> ( clean:: Crate , CrateAnalysis ) {
97-
88+ pub fn run_core ( search_paths : SearchPaths ,
89+ cfgs : Vec < String > ,
90+ externs : Externs ,
91+ input : Input ,
92+ triple : Option < String > ) -> ( clean:: Crate , RenderInfo )
93+ {
9894 // Parse, resolve, and typecheck the given crate.
9995
10096 let cpath = match input {
@@ -148,7 +144,7 @@ pub fn run_core(search_paths: SearchPaths, cfgs: Vec<String>, externs: Externs,
148144 let arenas = ty:: CtxtArenas :: new ( ) ;
149145 let hir_map = driver:: make_map ( & sess, & mut hir_forest) ;
150146
151- let krate_and_analysis = abort_on_err ( driver:: phase_3_run_analysis_passes ( & sess,
147+ abort_on_err ( driver:: phase_3_run_analysis_passes ( & sess,
152148 & cstore,
153149 hir_map,
154150 & arenas,
@@ -175,42 +171,20 @@ pub fn run_core(search_paths: SearchPaths, cfgs: Vec<String>, externs: Externs,
175171 map : & tcx. map ,
176172 maybe_typed : Typed ( tcx) ,
177173 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 ( ) ) ) ,
182174 all_crate_impls : RefCell :: new ( HashMap :: new ( ) ) ,
183175 deref_trait_did : Cell :: new ( None ) ,
176+ access_levels : RefCell :: new ( access_levels) ,
177+ external_traits : RefCell :: new ( HashMap :: new ( ) ) ,
178+ renderinfo : RefCell :: new ( Default :: default ( ) ) ,
184179 } ;
185180 debug ! ( "crate: {:?}" , ctxt. map. krate( ) ) ;
186181
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-
195182 let krate = {
196- let mut v = RustdocVisitor :: new ( & ctxt, Some ( & analysis ) ) ;
183+ let mut v = RustdocVisitor :: new ( & ctxt) ;
197184 v. visit ( ctxt. map . krate ( ) ) ;
198185 v. clean ( & ctxt)
199186 } ;
200187
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 ( )
188+ Some ( ( krate, ctxt. renderinfo . into_inner ( ) ) )
189+ } ) , & sess) . unwrap ( )
216190}
0 commit comments