@@ -20,6 +20,7 @@ use rustc::lint;
20
20
use rustc:: util:: nodemap:: FxHashMap ;
21
21
use rustc_trans;
22
22
use rustc_resolve as resolve;
23
+ use rustc_metadata:: creader:: CrateLoader ;
23
24
use rustc_metadata:: cstore:: CStore ;
24
25
25
26
use syntax:: codemap;
@@ -43,8 +44,9 @@ pub use rustc::session::search_paths::SearchPaths;
43
44
44
45
pub type ExternalPaths = FxHashMap < DefId , ( Vec < String > , clean:: TypeKind ) > ;
45
46
46
- pub struct DocContext < ' a , ' tcx : ' a > {
47
+ pub struct DocContext < ' a , ' tcx : ' a , ' rcx > {
47
48
pub tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
49
+ pub resolver : resolve:: Resolver < ' rcx > ,
48
50
pub populated_all_crate_impls : Cell < bool > ,
49
51
// Note that external items for which `doc(hidden)` applies to are shown as
50
52
// non-reachable while local items aren't. This is because we're reusing
@@ -67,7 +69,7 @@ pub struct DocContext<'a, 'tcx: 'a> {
67
69
pub lt_substs : RefCell < FxHashMap < DefId , clean:: Lifetime > > ,
68
70
}
69
71
70
- impl < ' a , ' tcx > DocContext < ' a , ' tcx > {
72
+ impl < ' a , ' tcx , ' rcx > DocContext < ' a , ' tcx , ' rcx > {
71
73
pub fn sess ( & self ) -> & session:: Session {
72
74
& self . tcx . sess
73
75
}
@@ -160,7 +162,13 @@ pub fn run_core(search_paths: SearchPaths,
160
162
161
163
let name = :: rustc_trans_utils:: link:: find_crate_name ( Some ( & sess) , & krate. attrs , & input) ;
162
164
163
- let driver:: ExpansionResult { defs, analysis, resolutions, mut hir_forest, .. } = {
165
+ let driver:: ExpansionResult {
166
+ expanded_crate,
167
+ defs,
168
+ analysis,
169
+ resolutions,
170
+ mut hir_forest
171
+ } = {
164
172
let result = driver:: phase_2_configure_and_expand ( & sess,
165
173
& cstore,
166
174
krate,
@@ -173,6 +181,8 @@ pub fn run_core(search_paths: SearchPaths,
173
181
} ;
174
182
175
183
let arenas = AllArenas :: new ( ) ;
184
+ let mut crate_loader = CrateLoader :: new ( & sess, & cstore, & name) ;
185
+ let resolver_arenas = resolve:: Resolver :: arenas ( ) ;
176
186
let hir_map = hir_map:: map_crate ( & sess, & * cstore, & mut hir_forest, & defs) ;
177
187
let output_filenames = driver:: build_output_filenames ( & input,
178
188
& None ,
@@ -205,8 +215,19 @@ pub fn run_core(search_paths: SearchPaths,
205
215
. collect ( )
206
216
} ;
207
217
218
+ // Set up a Resolver so that the doc cleaning can look up paths in the docs
219
+ let mut resolver = resolve:: Resolver :: new ( & sess,
220
+ & * cstore,
221
+ & expanded_crate,
222
+ & name,
223
+ resolve:: MakeGlobMap :: No ,
224
+ & mut crate_loader,
225
+ & resolver_arenas) ;
226
+ resolver. resolve_crate ( & expanded_crate) ;
227
+
208
228
let ctxt = DocContext {
209
229
tcx,
230
+ resolver,
210
231
populated_all_crate_impls : Cell :: new ( false ) ,
211
232
access_levels : RefCell :: new ( access_levels) ,
212
233
external_traits : Default :: default ( ) ,
0 commit comments