@@ -164,7 +164,7 @@ pub fn build_external_trait<'a, 'tcx>(cx: &DocContext, tcx: TyCtxt<'a, 'tcx, 'tc
164
164
did : DefId ) -> clean:: Trait {
165
165
let def = tcx. lookup_trait_def ( did) ;
166
166
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) ;
168
168
let generics = ( def. generics , & predicates) . clean ( cx) ;
169
169
let generics = filter_non_trait_generics ( did, generics) ;
170
170
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
178
178
179
179
fn build_external_function < ' a , ' tcx > ( cx : & DocContext , tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
180
180
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 {
183
183
ty:: TyFnDef ( .., ref f) => ( ( did, & f. sig ) . clean ( cx) , f. unsafety , f. abi ) ,
184
184
_ => panic ! ( "bad function" ) ,
185
185
} ;
@@ -190,10 +190,10 @@ fn build_external_function<'a, 'tcx>(cx: &DocContext, tcx: TyCtxt<'a, 'tcx, 'tcx
190
190
hir:: Constness :: NotConst
191
191
} ;
192
192
193
- let predicates = tcx. lookup_predicates ( did) ;
193
+ let predicates = tcx. item_predicates ( did) ;
194
194
clean:: Function {
195
195
decl : decl,
196
- generics : ( t . generics , & predicates) . clean ( cx) ,
196
+ generics : ( tcx . item_generics ( did ) , & predicates) . clean ( cx) ,
197
197
unsafety : style,
198
198
constness : constness,
199
199
abi : abi,
@@ -202,20 +202,18 @@ fn build_external_function<'a, 'tcx>(cx: &DocContext, tcx: TyCtxt<'a, 'tcx, 'tcx
202
202
203
203
fn build_enum < ' a , ' tcx > ( cx : & DocContext , tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
204
204
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) ;
207
206
208
207
clean:: Enum {
209
- generics : ( t . generics , & predicates) . clean ( cx) ,
208
+ generics : ( tcx . item_generics ( did ) , & predicates) . clean ( cx) ,
210
209
variants_stripped : false ,
211
210
variants : tcx. lookup_adt_def ( did) . variants . clean ( cx) ,
212
211
}
213
212
}
214
213
215
214
fn build_struct < ' a , ' tcx > ( cx : & DocContext , tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
216
215
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) ;
219
217
let variant = tcx. lookup_adt_def ( did) . struct_variant ( ) ;
220
218
221
219
clean:: Struct {
@@ -224,34 +222,32 @@ fn build_struct<'a, 'tcx>(cx: &DocContext, tcx: TyCtxt<'a, 'tcx, 'tcx>,
224
222
CtorKind :: Fn => doctree:: Tuple ,
225
223
CtorKind :: Const => doctree:: Unit ,
226
224
} ,
227
- generics : ( t . generics , & predicates) . clean ( cx) ,
225
+ generics : ( tcx . item_generics ( did ) , & predicates) . clean ( cx) ,
228
226
fields : variant. fields . clean ( cx) ,
229
227
fields_stripped : false ,
230
228
}
231
229
}
232
230
233
231
fn build_union < ' a , ' tcx > ( cx : & DocContext , tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
234
232
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) ;
237
234
let variant = tcx. lookup_adt_def ( did) . struct_variant ( ) ;
238
235
239
236
clean:: Union {
240
237
struct_type : doctree:: Plain ,
241
- generics : ( t . generics , & predicates) . clean ( cx) ,
238
+ generics : ( tcx . item_generics ( did ) , & predicates) . clean ( cx) ,
242
239
fields : variant. fields . clean ( cx) ,
243
240
fields_stripped : false ,
244
241
}
245
242
}
246
243
247
244
fn build_type_alias < ' a , ' tcx > ( cx : & DocContext , tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
248
245
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) ;
251
247
252
248
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) ,
255
251
}
256
252
}
257
253
@@ -354,8 +350,7 @@ pub fn build_impl<'a, 'tcx>(cx: &DocContext,
354
350
} ) ;
355
351
}
356
352
357
- let ty = tcx. lookup_item_type ( did) ;
358
- let for_ = ty. ty . clean ( cx) ;
353
+ let for_ = tcx. item_type ( did) . clean ( cx) ;
359
354
360
355
// Only inline impl if the implementing type is
361
356
// reachable in rustdoc generated documentation
@@ -365,11 +360,10 @@ pub fn build_impl<'a, 'tcx>(cx: &DocContext,
365
360
}
366
361
}
367
362
368
- let predicates = tcx. lookup_predicates ( did) ;
363
+ let predicates = tcx. item_predicates ( did) ;
369
364
let trait_items = tcx. associated_items ( did) . filter_map ( |item| {
370
365
match item. kind {
371
366
ty:: AssociatedKind :: Const => {
372
- let type_scheme = tcx. lookup_item_type ( item. def_id ) ;
373
367
let default = if item. has_value {
374
368
Some ( pprust:: expr_to_string (
375
369
lookup_const_by_id ( tcx, item. def_id , None ) . unwrap ( ) . 0 ) )
@@ -379,7 +373,7 @@ pub fn build_impl<'a, 'tcx>(cx: &DocContext,
379
373
Some ( clean:: Item {
380
374
name : Some ( item. name . clean ( cx) ) ,
381
375
inner : clean:: AssociatedConstItem (
382
- type_scheme . ty . clean ( cx) ,
376
+ tcx . item_type ( item . def_id ) . clean ( cx) ,
383
377
default,
384
378
) ,
385
379
source : clean:: Span :: empty ( ) ,
@@ -419,7 +413,7 @@ pub fn build_impl<'a, 'tcx>(cx: &DocContext,
419
413
}
420
414
ty:: AssociatedKind :: Type => {
421
415
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) ,
423
417
generics : clean:: Generics {
424
418
lifetimes : vec ! [ ] ,
425
419
type_params : vec ! [ ] ,
@@ -463,7 +457,7 @@ pub fn build_impl<'a, 'tcx>(cx: &DocContext,
463
457
provided_trait_methods : provided,
464
458
trait_ : trait_,
465
459
for_ : for_,
466
- generics : ( ty . generics , & predicates) . clean ( cx) ,
460
+ generics : ( tcx . item_generics ( did ) , & predicates) . clean ( cx) ,
467
461
items : trait_items,
468
462
polarity : Some ( polarity. clean ( cx) ) ,
469
463
} ) ,
@@ -514,7 +508,7 @@ fn build_const<'a, 'tcx>(cx: &DocContext, tcx: TyCtxt<'a, 'tcx, 'tcx>,
514
508
debug ! ( "got snippet {}" , sn) ;
515
509
516
510
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) ) ,
518
512
expr : sn
519
513
}
520
514
}
@@ -523,7 +517,7 @@ fn build_static<'a, 'tcx>(cx: &DocContext, tcx: TyCtxt<'a, 'tcx, 'tcx>,
523
517
did : DefId ,
524
518
mutable : bool ) -> clean:: Static {
525
519
clean:: Static {
526
- type_ : tcx. lookup_item_type ( did) . ty . clean ( cx) ,
520
+ type_ : tcx. item_type ( did) . clean ( cx) ,
527
521
mutability : if mutable { clean:: Mutable } else { clean:: Immutable } ,
528
522
expr : "\n \n \n " . to_string ( ) , // trigger the "[definition]" links
529
523
}
0 commit comments