@@ -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,24 @@ 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 Externs = HashMap < String , Vec < String > > ;
50
+ pub type ExternalPaths = HashMap < DefId , ( Vec < String > , clean:: TypeKind ) > ;
50
51
51
52
pub struct DocContext < ' a , ' tcx : ' a > {
52
53
pub map : & ' a hir_map:: Map < ' tcx > ,
53
54
pub maybe_typed : MaybeTyped < ' a , ' tcx > ,
54
55
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
56
pub all_crate_impls : RefCell < HashMap < ast:: CrateNum , Vec < clean:: Item > > > ,
60
57
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 > > ,
61
67
}
62
68
63
69
impl < ' b , ' tcx > DocContext < ' b , ' tcx > {
@@ -81,20 +87,23 @@ impl<'b, 'tcx> DocContext<'b, 'tcx> {
81
87
}
82
88
}
83
89
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 ;
90
92
}
91
93
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
+ }
93
99
94
- pub fn run_core ( search_paths : SearchPaths , cfgs : Vec < String > , externs : Externs ,
95
- input : Input , triple : Option < String > )
96
- -> ( clean:: Crate , CrateAnalysis ) {
97
100
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
+ {
98
107
// Parse, resolve, and typecheck the given crate.
99
108
100
109
let cpath = match input {
@@ -148,7 +157,7 @@ pub fn run_core(search_paths: SearchPaths, cfgs: Vec<String>, externs: Externs,
148
157
let arenas = ty:: CtxtArenas :: new ( ) ;
149
158
let hir_map = driver:: make_map ( & sess, & mut hir_forest) ;
150
159
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,
152
161
& cstore,
153
162
hir_map,
154
163
& arenas,
@@ -175,42 +184,20 @@ pub fn run_core(search_paths: SearchPaths, cfgs: Vec<String>, externs: Externs,
175
184
map : & tcx. map ,
176
185
maybe_typed : Typed ( tcx) ,
177
186
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
187
all_crate_impls : RefCell :: new ( HashMap :: new ( ) ) ,
183
188
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 ( ) ) ,
184
192
} ;
185
193
debug ! ( "crate: {:?}" , ctxt. map. krate( ) ) ;
186
194
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
195
let krate = {
196
- let mut v = RustdocVisitor :: new ( & ctxt, Some ( & analysis ) ) ;
196
+ let mut v = RustdocVisitor :: new ( & ctxt) ;
197
197
v. visit ( ctxt. map . krate ( ) ) ;
198
198
v. clean ( & ctxt)
199
199
} ;
200
200
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 ( )
216
203
}
0 commit comments