@@ -29,12 +29,13 @@ use syntax::feature_gate::UnstableFeatures;
29
29
use syntax:: parse:: token;
30
30
31
31
use std:: cell:: { RefCell , Cell } ;
32
- use std:: collections:: { HashMap , HashSet } ;
32
+ use std:: collections:: HashMap ;
33
33
use std:: rc:: Rc ;
34
34
35
35
use visit_ast:: RustdocVisitor ;
36
36
use clean;
37
37
use clean:: Clean ;
38
+ use html:: render:: RenderInfo ;
38
39
39
40
pub use rustc:: session:: config:: Input ;
40
41
pub use rustc:: session:: search_paths:: SearchPaths ;
@@ -45,19 +46,20 @@ pub enum MaybeTyped<'a, 'tcx: 'a> {
45
46
NotTyped ( & ' a session:: Session )
46
47
}
47
48
48
- pub type ExternalPaths = RefCell < Option < HashMap < DefId ,
49
- ( Vec < String > , clean:: TypeKind ) > > > ;
49
+ pub type ExternalPaths = HashMap < DefId , ( Vec < String > , clean:: TypeKind ) > ;
50
50
51
51
pub struct DocContext < ' a , ' tcx : ' a > {
52
52
pub map : & ' a hir_map:: Map < ' tcx > ,
53
53
pub maybe_typed : MaybeTyped < ' a , ' tcx > ,
54
54
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 > > > ,
59
55
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 > ,
60
60
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 > > ,
61
63
}
62
64
63
65
impl < ' b , ' tcx > DocContext < ' b , ' tcx > {
@@ -81,20 +83,14 @@ impl<'b, 'tcx> DocContext<'b, 'tcx> {
81
83
}
82
84
}
83
85
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
-
92
86
pub type Externs = HashMap < String , Vec < String > > ;
93
87
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
+ {
98
94
// Parse, resolve, and typecheck the given crate.
99
95
100
96
let cpath = match input {
@@ -148,7 +144,7 @@ pub fn run_core(search_paths: SearchPaths, cfgs: Vec<String>, externs: Externs,
148
144
let arenas = ty:: CtxtArenas :: new ( ) ;
149
145
let hir_map = driver:: make_map ( & sess, & mut hir_forest) ;
150
146
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,
152
148
& cstore,
153
149
hir_map,
154
150
& arenas,
@@ -175,42 +171,20 @@ pub fn run_core(search_paths: SearchPaths, cfgs: Vec<String>, externs: Externs,
175
171
map : & tcx. map ,
176
172
maybe_typed : Typed ( tcx) ,
177
173
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 ( ) ) ) ,
182
174
all_crate_impls : RefCell :: new ( HashMap :: new ( ) ) ,
183
175
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 ( ) ) ,
184
179
} ;
185
180
debug ! ( "crate: {:?}" , ctxt. map. krate( ) ) ;
186
181
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
-
195
182
let krate = {
196
- let mut v = RustdocVisitor :: new ( & ctxt, Some ( & analysis ) ) ;
183
+ let mut v = RustdocVisitor :: new ( & ctxt) ;
197
184
v. visit ( ctxt. map . krate ( ) ) ;
198
185
v. clean ( & ctxt)
199
186
} ;
200
187
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 ( )
216
190
}
0 commit comments