@@ -43,7 +43,7 @@ crate fn build_index<'tcx>(krate: &clean::Crate, cache: &mut Cache, tcx: TyCtxt<
43
43
desc,
44
44
parent : Some ( did) ,
45
45
parent_idx : None ,
46
- search_type : get_index_search_type ( item, tcx) ,
46
+ search_type : get_index_search_type ( item, tcx, cache ) ,
47
47
aliases : item. attrs . get_doc_aliases ( ) ,
48
48
} ) ;
49
49
}
@@ -191,11 +191,12 @@ crate fn build_index<'tcx>(krate: &clean::Crate, cache: &mut Cache, tcx: TyCtxt<
191
191
crate fn get_index_search_type < ' tcx > (
192
192
item : & clean:: Item ,
193
193
tcx : TyCtxt < ' tcx > ,
194
+ cache : & Cache ,
194
195
) -> Option < IndexItemFunctionType > {
195
196
let ( mut inputs, mut output) = match * item. kind {
196
- clean:: FunctionItem ( ref f) => get_all_types ( & f. generics , & f. decl , tcx) ,
197
- clean:: MethodItem ( ref m, _) => get_all_types ( & m. generics , & m. decl , tcx) ,
198
- clean:: TyMethodItem ( ref m) => get_all_types ( & m. generics , & m. decl , tcx) ,
197
+ clean:: FunctionItem ( ref f) => get_all_types ( & f. generics , & f. decl , tcx, cache ) ,
198
+ clean:: MethodItem ( ref m, _) => get_all_types ( & m. generics , & m. decl , tcx, cache ) ,
199
+ clean:: TyMethodItem ( ref m) => get_all_types ( & m. generics , & m. decl , tcx, cache ) ,
199
200
_ => return None ,
200
201
} ;
201
202
@@ -249,12 +250,14 @@ crate fn get_real_types<'tcx>(
249
250
tcx : TyCtxt < ' tcx > ,
250
251
recurse : usize ,
251
252
res : & mut Vec < TypeWithKind > ,
253
+ cache : & Cache ,
252
254
) {
253
255
fn insert_ty (
254
256
res : & mut Vec < TypeWithKind > ,
255
257
tcx : TyCtxt < ' _ > ,
256
258
ty : Type ,
257
259
mut generics : Vec < TypeWithKind > ,
260
+ cache : & Cache ,
258
261
) {
259
262
let is_full_generic = ty. is_full_generic ( ) ;
260
263
@@ -306,7 +309,7 @@ crate fn get_real_types<'tcx>(
306
309
// We remove the name of the full generic because we have no use for it.
307
310
index_ty. name = Some ( String :: new ( ) ) ;
308
311
res. push ( TypeWithKind :: from ( ( index_ty, ItemType :: Generic ) ) ) ;
309
- } else if let Some ( kind) = ty. def_id_no_primitives ( ) . map ( |did| tcx. def_kind ( did) . into ( ) ) {
312
+ } else if let Some ( kind) = ty. def_id ( cache ) . map ( |did| tcx. def_kind ( did) . into ( ) ) {
310
313
res. push ( TypeWithKind :: from ( ( index_ty, kind) ) ) ;
311
314
} else if ty. is_primitive ( ) {
312
315
// This is a primitive, let's store it as such.
@@ -321,9 +324,7 @@ crate fn get_real_types<'tcx>(
321
324
322
325
if let Type :: Generic ( arg_s) = * arg {
323
326
if let Some ( where_pred) = generics. where_predicates . iter ( ) . find ( |g| match g {
324
- WherePredicate :: BoundPredicate { ty, .. } => {
325
- ty. def_id_no_primitives ( ) == arg. def_id_no_primitives ( )
326
- }
327
+ WherePredicate :: BoundPredicate { ty, .. } => ty. def_id ( cache) == arg. def_id ( cache) ,
327
328
_ => false ,
328
329
} ) {
329
330
let mut ty_generics = Vec :: new ( ) ;
@@ -335,31 +336,38 @@ crate fn get_real_types<'tcx>(
335
336
continue ;
336
337
}
337
338
if let Some ( ty) = x. get_type ( ) {
338
- get_real_types ( generics, & ty, tcx, recurse + 1 , & mut ty_generics) ;
339
+ get_real_types (
340
+ generics,
341
+ & ty,
342
+ tcx,
343
+ recurse + 1 ,
344
+ & mut ty_generics,
345
+ cache,
346
+ ) ;
339
347
}
340
348
}
341
349
}
342
350
}
343
- insert_ty ( res, tcx, arg. clone ( ) , ty_generics) ;
351
+ insert_ty ( res, tcx, arg. clone ( ) , ty_generics, cache ) ;
344
352
}
345
353
if let Some ( bound) = generics. params . iter ( ) . find ( |g| g. is_type ( ) && g. name == arg_s) {
346
354
let mut ty_generics = Vec :: new ( ) ;
347
355
for bound in bound. get_bounds ( ) . unwrap_or ( & [ ] ) {
348
356
if let Some ( path) = bound. get_trait_path ( ) {
349
357
let ty = Type :: ResolvedPath { did : path. def_id ( ) , path } ;
350
- get_real_types ( generics, & ty, tcx, recurse + 1 , & mut ty_generics) ;
358
+ get_real_types ( generics, & ty, tcx, recurse + 1 , & mut ty_generics, cache ) ;
351
359
}
352
360
}
353
- insert_ty ( res, tcx, arg. clone ( ) , ty_generics) ;
361
+ insert_ty ( res, tcx, arg. clone ( ) , ty_generics, cache ) ;
354
362
}
355
363
} else {
356
364
let mut ty_generics = Vec :: new ( ) ;
357
365
if let Some ( arg_generics) = arg. generics ( ) {
358
366
for gen in arg_generics. iter ( ) {
359
- get_real_types ( generics, gen, tcx, recurse + 1 , & mut ty_generics) ;
367
+ get_real_types ( generics, gen, tcx, recurse + 1 , & mut ty_generics, cache ) ;
360
368
}
361
369
}
362
- insert_ty ( res, tcx, arg. clone ( ) , ty_generics) ;
370
+ insert_ty ( res, tcx, arg. clone ( ) , ty_generics, cache ) ;
363
371
}
364
372
}
365
373
@@ -371,6 +379,7 @@ crate fn get_all_types<'tcx>(
371
379
generics : & Generics ,
372
380
decl : & FnDecl ,
373
381
tcx : TyCtxt < ' tcx > ,
382
+ cache : & Cache ,
374
383
) -> ( Vec < TypeWithKind > , Vec < TypeWithKind > ) {
375
384
let mut all_types = Vec :: new ( ) ;
376
385
for arg in decl. inputs . values . iter ( ) {
@@ -380,14 +389,13 @@ crate fn get_all_types<'tcx>(
380
389
// FIXME: performance wise, it'd be much better to move `args` declaration outside of the
381
390
// loop and replace this line with `args.clear()`.
382
391
let mut args = Vec :: new ( ) ;
383
- get_real_types ( generics, & arg. type_ , tcx, 0 , & mut args) ;
392
+ get_real_types ( generics, & arg. type_ , tcx, 0 , & mut args, cache ) ;
384
393
if !args. is_empty ( ) {
385
394
// FIXME: once back to performance improvements, replace this line with:
386
395
// `all_types.extend(args.drain(..));`.
387
396
all_types. extend ( args) ;
388
397
} else {
389
- if let Some ( kind) = arg. type_ . def_id_no_primitives ( ) . map ( |did| tcx. def_kind ( did) . into ( ) )
390
- {
398
+ if let Some ( kind) = arg. type_ . def_id ( cache) . map ( |did| tcx. def_kind ( did) . into ( ) ) {
391
399
all_types. push ( TypeWithKind :: from ( ( get_index_type ( & arg. type_ , vec ! [ ] ) , kind) ) ) ;
392
400
}
393
401
}
@@ -396,11 +404,9 @@ crate fn get_all_types<'tcx>(
396
404
let mut ret_types = Vec :: new ( ) ;
397
405
match decl. output {
398
406
FnRetTy :: Return ( ref return_type) => {
399
- get_real_types ( generics, return_type, tcx, 0 , & mut ret_types) ;
407
+ get_real_types ( generics, return_type, tcx, 0 , & mut ret_types, cache ) ;
400
408
if ret_types. is_empty ( ) {
401
- if let Some ( kind) =
402
- return_type. def_id_no_primitives ( ) . map ( |did| tcx. def_kind ( did) . into ( ) )
403
- {
409
+ if let Some ( kind) = return_type. def_id ( cache) . map ( |did| tcx. def_kind ( did) . into ( ) ) {
404
410
ret_types. push ( TypeWithKind :: from ( ( get_index_type ( return_type, vec ! [ ] ) , kind) ) ) ;
405
411
}
406
412
}
0 commit comments