@@ -16,8 +16,7 @@ use syntax::ast;
16
16
use syntax:: attr:: AttrMetaMethods ;
17
17
use rustc_front:: hir;
18
18
19
- use rustc:: metadata:: csearch;
20
- use rustc:: metadata:: decoder;
19
+ use rustc:: metadata:: util:: { self as mdutil, CrateStore } ;
21
20
use rustc:: middle:: def;
22
21
use rustc:: middle:: def_id:: DefId ;
23
22
use rustc:: middle:: ty;
@@ -129,8 +128,7 @@ fn try_inline_def(cx: &DocContext, tcx: &ty::ctxt,
129
128
130
129
pub fn load_attrs ( cx : & DocContext , tcx : & ty:: ctxt ,
131
130
did : DefId ) -> Vec < clean:: Attribute > {
132
- let attrs = csearch:: get_item_attrs ( & tcx. sess . cstore , did) ;
133
- attrs. into_iter ( ) . map ( |a| a. clean ( cx) ) . collect ( )
131
+ tcx. get_attrs ( did) . iter ( ) . map ( |a| a. clean ( cx) ) . collect ( )
134
132
}
135
133
136
134
/// Record an external fully qualified name in the external_paths cache.
@@ -140,7 +138,7 @@ pub fn load_attrs(cx: &DocContext, tcx: &ty::ctxt,
140
138
pub fn record_extern_fqn ( cx : & DocContext , did : DefId , kind : clean:: TypeKind ) {
141
139
match cx. tcx_opt ( ) {
142
140
Some ( tcx) => {
143
- let fqn = csearch :: get_item_path ( tcx, did) ;
141
+ let fqn = tcx. sess . cstore . item_path ( did) ;
144
142
let fqn = fqn. into_iter ( ) . map ( |i| i. to_string ( ) ) . collect ( ) ;
145
143
cx. external_paths . borrow_mut ( ) . as_mut ( ) . unwrap ( ) . insert ( did, ( fqn, kind) ) ;
146
144
}
@@ -211,7 +209,7 @@ fn build_type(cx: &DocContext, tcx: &ty::ctxt, did: DefId) -> clean::ItemEnum {
211
209
let t = tcx. lookup_item_type ( did) ;
212
210
let predicates = tcx. lookup_predicates ( did) ;
213
211
match t. ty . sty {
214
- ty:: TyEnum ( edef, _) if !csearch :: is_typedef ( & tcx. sess . cstore , did) => {
212
+ ty:: TyEnum ( edef, _) if !tcx. sess . cstore . is_typedef ( did) => {
215
213
return clean:: EnumItem ( clean:: Enum {
216
214
generics : ( & t. generics , & predicates, subst:: TypeSpace ) . clean ( cx) ,
217
215
variants_stripped : false ,
@@ -250,23 +248,19 @@ pub fn build_impls(cx: &DocContext, tcx: &ty::ctxt,
250
248
// type being inlined, but impls can also be used when generating
251
249
// documentation for primitives (no way to find those specifically).
252
250
if cx. populated_crate_impls . borrow_mut ( ) . insert ( did. krate ) {
253
- csearch:: each_top_level_item_of_crate ( & tcx. sess . cstore ,
254
- did. krate ,
255
- |def, _, _| {
256
- populate_impls ( cx, tcx, def, & mut impls)
257
- } ) ;
251
+ for item in tcx. sess . cstore . crate_top_level_items ( did. krate ) {
252
+ populate_impls ( cx, tcx, item. def , & mut impls) ;
253
+ }
258
254
259
255
fn populate_impls ( cx : & DocContext , tcx : & ty:: ctxt ,
260
- def : decoder :: DefLike ,
256
+ def : mdutil :: DefLike ,
261
257
impls : & mut Vec < clean:: Item > ) {
262
258
match def {
263
- decoder:: DlImpl ( did) => build_impl ( cx, tcx, did, impls) ,
264
- decoder:: DlDef ( def:: DefMod ( did) ) => {
265
- csearch:: each_child_of_item ( & tcx. sess . cstore ,
266
- did,
267
- |def, _, _| {
268
- populate_impls ( cx, tcx, def, impls)
269
- } )
259
+ mdutil:: DlImpl ( did) => build_impl ( cx, tcx, did, impls) ,
260
+ mdutil:: DlDef ( def:: DefMod ( did) ) => {
261
+ for item in tcx. sess . cstore . item_children ( did) {
262
+ populate_impls ( cx, tcx, item. def , impls)
263
+ }
270
264
}
271
265
_ => { }
272
266
}
@@ -285,7 +279,7 @@ pub fn build_impl(cx: &DocContext,
285
279
}
286
280
287
281
let attrs = load_attrs ( cx, tcx, did) ;
288
- let associated_trait = csearch :: get_impl_trait ( tcx, did) ;
282
+ let associated_trait = tcx. impl_trait_ref ( did) ;
289
283
if let Some ( ref t) = associated_trait {
290
284
// If this is an impl for a #[doc(hidden)] trait, be sure to not inline
291
285
let trait_attrs = load_attrs ( cx, tcx, t. def_id ) ;
@@ -295,7 +289,7 @@ pub fn build_impl(cx: &DocContext,
295
289
}
296
290
297
291
// If this is a defaulted impl, then bail out early here
298
- if csearch :: is_default_impl ( & tcx. sess . cstore , did) {
292
+ if tcx. sess . cstore . is_default_impl ( did) {
299
293
return ret. push ( clean:: Item {
300
294
inner : clean:: DefaultImplItem ( clean:: DefaultImpl {
301
295
// FIXME: this should be decoded
@@ -315,7 +309,7 @@ pub fn build_impl(cx: &DocContext,
315
309
}
316
310
317
311
let predicates = tcx. lookup_predicates ( did) ;
318
- let trait_items = csearch :: get_impl_items ( & tcx. sess . cstore , did)
312
+ let trait_items = tcx. sess . cstore . impl_items ( did)
319
313
. iter ( )
320
314
. filter_map ( |did| {
321
315
let did = did. def_id ( ) ;
@@ -393,7 +387,7 @@ pub fn build_impl(cx: &DocContext,
393
387
}
394
388
}
395
389
} ) . collect :: < Vec < _ > > ( ) ;
396
- let polarity = csearch :: get_impl_polarity ( tcx, did) ;
390
+ let polarity = tcx. trait_impl_polarity ( did) ;
397
391
let ty = tcx. lookup_item_type ( did) ;
398
392
let trait_ = associated_trait. clean ( cx) . map ( |bound| {
399
393
match bound {
@@ -454,24 +448,24 @@ fn build_module(cx: &DocContext, tcx: &ty::ctxt,
454
448
// two namespaces, so the target may be listed twice. Make sure we only
455
449
// visit each node at most once.
456
450
let mut visited = HashSet :: new ( ) ;
457
- csearch :: each_child_of_item ( & tcx. sess . cstore , did, |def , _ , vis| {
458
- match def {
459
- decoder :: DlDef ( def:: DefForeignMod ( did) ) => {
451
+ for item in tcx. sess . cstore . item_children ( did) {
452
+ match item . def {
453
+ mdutil :: DlDef ( def:: DefForeignMod ( did) ) => {
460
454
fill_in ( cx, tcx, did, items) ;
461
455
}
462
- decoder :: DlDef ( def) if vis == hir:: Public => {
456
+ mdutil :: DlDef ( def) if item . vis == hir:: Public => {
463
457
if !visited. insert ( def) { return }
464
458
match try_inline_def ( cx, tcx, def) {
465
459
Some ( i) => items. extend ( i) ,
466
460
None => { }
467
461
}
468
462
}
469
- decoder :: DlDef ( ..) => { }
463
+ mdutil :: DlDef ( ..) => { }
470
464
// All impls were inlined above
471
- decoder :: DlImpl ( ..) => { }
472
- decoder :: DlField => panic ! ( "unimplemented field" ) ,
465
+ mdutil :: DlImpl ( ..) => { }
466
+ mdutil :: DlField => panic ! ( "unimplemented field" ) ,
473
467
}
474
- } ) ;
468
+ }
475
469
}
476
470
}
477
471
0 commit comments