@@ -164,7 +164,7 @@ pub fn build_external_trait<'a, 'tcx>(cx: &DocContext, tcx: TyCtxt<'a, 'tcx, 'tc
164164 did : DefId ) -> clean:: Trait {
165165 let def = tcx. lookup_trait_def ( did) ;
166166 let trait_items = tcx. associated_items ( did) . map ( |item| item. clean ( cx) ) . collect ( ) ;
167- let predicates = tcx. lookup_predicates ( did) ;
167+ let predicates = tcx. item_predicates ( did) ;
168168 let generics = ( def. generics , & predicates) . clean ( cx) ;
169169 let generics = filter_non_trait_generics ( did, generics) ;
170170 let ( generics, supertrait_bounds) = separate_supertrait_bounds ( generics) ;
@@ -178,8 +178,8 @@ pub fn build_external_trait<'a, 'tcx>(cx: &DocContext, tcx: TyCtxt<'a, 'tcx, 'tc
178178
179179fn build_external_function < ' a , ' tcx > ( cx : & DocContext , tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
180180 did : DefId ) -> clean:: Function {
181- let t = tcx. lookup_item_type ( did) ;
182- let ( decl, style, abi) = match t . ty . sty {
181+ let ty = tcx. item_type ( did) ;
182+ let ( decl, style, abi) = match ty. sty {
183183 ty:: TyFnDef ( .., ref f) => ( ( did, & f. sig ) . clean ( cx) , f. unsafety , f. abi ) ,
184184 _ => panic ! ( "bad function" ) ,
185185 } ;
@@ -190,10 +190,10 @@ fn build_external_function<'a, 'tcx>(cx: &DocContext, tcx: TyCtxt<'a, 'tcx, 'tcx
190190 hir:: Constness :: NotConst
191191 } ;
192192
193- let predicates = tcx. lookup_predicates ( did) ;
193+ let predicates = tcx. item_predicates ( did) ;
194194 clean:: Function {
195195 decl : decl,
196- generics : ( t . generics , & predicates) . clean ( cx) ,
196+ generics : ( tcx . item_generics ( did ) , & predicates) . clean ( cx) ,
197197 unsafety : style,
198198 constness : constness,
199199 abi : abi,
@@ -202,20 +202,18 @@ fn build_external_function<'a, 'tcx>(cx: &DocContext, tcx: TyCtxt<'a, 'tcx, 'tcx
202202
203203fn build_enum < ' a , ' tcx > ( cx : & DocContext , tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
204204 did : DefId ) -> clean:: Enum {
205- let t = tcx. lookup_item_type ( did) ;
206- let predicates = tcx. lookup_predicates ( did) ;
205+ let predicates = tcx. item_predicates ( did) ;
207206
208207 clean:: Enum {
209- generics : ( t . generics , & predicates) . clean ( cx) ,
208+ generics : ( tcx . item_generics ( did ) , & predicates) . clean ( cx) ,
210209 variants_stripped : false ,
211210 variants : tcx. lookup_adt_def ( did) . variants . clean ( cx) ,
212211 }
213212}
214213
215214fn build_struct < ' a , ' tcx > ( cx : & DocContext , tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
216215 did : DefId ) -> clean:: Struct {
217- let t = tcx. lookup_item_type ( did) ;
218- let predicates = tcx. lookup_predicates ( did) ;
216+ let predicates = tcx. item_predicates ( did) ;
219217 let variant = tcx. lookup_adt_def ( did) . struct_variant ( ) ;
220218
221219 clean:: Struct {
@@ -224,34 +222,32 @@ fn build_struct<'a, 'tcx>(cx: &DocContext, tcx: TyCtxt<'a, 'tcx, 'tcx>,
224222 CtorKind :: Fn => doctree:: Tuple ,
225223 CtorKind :: Const => doctree:: Unit ,
226224 } ,
227- generics : ( t . generics , & predicates) . clean ( cx) ,
225+ generics : ( tcx . item_generics ( did ) , & predicates) . clean ( cx) ,
228226 fields : variant. fields . clean ( cx) ,
229227 fields_stripped : false ,
230228 }
231229}
232230
233231fn build_union < ' a , ' tcx > ( cx : & DocContext , tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
234232 did : DefId ) -> clean:: Union {
235- let t = tcx. lookup_item_type ( did) ;
236- let predicates = tcx. lookup_predicates ( did) ;
233+ let predicates = tcx. item_predicates ( did) ;
237234 let variant = tcx. lookup_adt_def ( did) . struct_variant ( ) ;
238235
239236 clean:: Union {
240237 struct_type : doctree:: Plain ,
241- generics : ( t . generics , & predicates) . clean ( cx) ,
238+ generics : ( tcx . item_generics ( did ) , & predicates) . clean ( cx) ,
242239 fields : variant. fields . clean ( cx) ,
243240 fields_stripped : false ,
244241 }
245242}
246243
247244fn build_type_alias < ' a , ' tcx > ( cx : & DocContext , tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
248245 did : DefId ) -> clean:: Typedef {
249- let t = tcx. lookup_item_type ( did) ;
250- let predicates = tcx. lookup_predicates ( did) ;
246+ let predicates = tcx. item_predicates ( did) ;
251247
252248 clean:: Typedef {
253- type_ : t . ty . clean ( cx) ,
254- generics : ( t . generics , & predicates) . clean ( cx) ,
249+ type_ : tcx . item_type ( did ) . clean ( cx) ,
250+ generics : ( tcx . item_generics ( did ) , & predicates) . clean ( cx) ,
255251 }
256252}
257253
@@ -354,8 +350,7 @@ pub fn build_impl<'a, 'tcx>(cx: &DocContext,
354350 } ) ;
355351 }
356352
357- let ty = tcx. lookup_item_type ( did) ;
358- let for_ = ty. ty . clean ( cx) ;
353+ let for_ = tcx. item_type ( did) . clean ( cx) ;
359354
360355 // Only inline impl if the implementing type is
361356 // reachable in rustdoc generated documentation
@@ -365,11 +360,10 @@ pub fn build_impl<'a, 'tcx>(cx: &DocContext,
365360 }
366361 }
367362
368- let predicates = tcx. lookup_predicates ( did) ;
363+ let predicates = tcx. item_predicates ( did) ;
369364 let trait_items = tcx. associated_items ( did) . filter_map ( |item| {
370365 match item. kind {
371366 ty:: AssociatedKind :: Const => {
372- let type_scheme = tcx. lookup_item_type ( item. def_id ) ;
373367 let default = if item. has_value {
374368 Some ( pprust:: expr_to_string (
375369 lookup_const_by_id ( tcx, item. def_id , None ) . unwrap ( ) . 0 ) )
@@ -379,7 +373,7 @@ pub fn build_impl<'a, 'tcx>(cx: &DocContext,
379373 Some ( clean:: Item {
380374 name : Some ( item. name . clean ( cx) ) ,
381375 inner : clean:: AssociatedConstItem (
382- type_scheme . ty . clean ( cx) ,
376+ tcx . item_type ( item . def_id ) . clean ( cx) ,
383377 default,
384378 ) ,
385379 source : clean:: Span :: empty ( ) ,
@@ -419,7 +413,7 @@ pub fn build_impl<'a, 'tcx>(cx: &DocContext,
419413 }
420414 ty:: AssociatedKind :: Type => {
421415 let typedef = clean:: Typedef {
422- type_ : tcx. lookup_item_type ( item. def_id ) . ty . clean ( cx) ,
416+ type_ : tcx. item_type ( item. def_id ) . clean ( cx) ,
423417 generics : clean:: Generics {
424418 lifetimes : vec ! [ ] ,
425419 type_params : vec ! [ ] ,
@@ -463,7 +457,7 @@ pub fn build_impl<'a, 'tcx>(cx: &DocContext,
463457 provided_trait_methods : provided,
464458 trait_ : trait_,
465459 for_ : for_,
466- generics : ( ty . generics , & predicates) . clean ( cx) ,
460+ generics : ( tcx . item_generics ( did ) , & predicates) . clean ( cx) ,
467461 items : trait_items,
468462 polarity : Some ( polarity. clean ( cx) ) ,
469463 } ) ,
@@ -514,7 +508,7 @@ fn build_const<'a, 'tcx>(cx: &DocContext, tcx: TyCtxt<'a, 'tcx, 'tcx>,
514508 debug ! ( "got snippet {}" , sn) ;
515509
516510 clean:: Constant {
517- type_ : ty. map ( |t| t. clean ( cx) ) . unwrap_or_else ( || tcx. lookup_item_type ( did) . ty . clean ( cx) ) ,
511+ type_ : ty. map ( |t| t. clean ( cx) ) . unwrap_or_else ( || tcx. item_type ( did) . clean ( cx) ) ,
518512 expr : sn
519513 }
520514}
@@ -523,7 +517,7 @@ fn build_static<'a, 'tcx>(cx: &DocContext, tcx: TyCtxt<'a, 'tcx, 'tcx>,
523517 did : DefId ,
524518 mutable : bool ) -> clean:: Static {
525519 clean:: Static {
526- type_ : tcx. lookup_item_type ( did) . ty . clean ( cx) ,
520+ type_ : tcx. item_type ( did) . clean ( cx) ,
527521 mutability : if mutable { clean:: Mutable } else { clean:: Immutable } ,
528522 expr : "\n \n \n " . to_string ( ) , // trigger the "[definition]" links
529523 }
0 commit comments