@@ -42,7 +42,7 @@ crate fn build_index<'tcx>(krate: &clean::Crate, cache: &mut Cache, tcx: TyCtxt<
42
42
desc,
43
43
parent : Some ( did) ,
44
44
parent_idx : None ,
45
- search_type : get_index_search_type ( item, tcx) ,
45
+ search_type : get_index_search_type ( item, tcx, cache ) ,
46
46
aliases : item. attrs . get_doc_aliases ( ) ,
47
47
} ) ;
48
48
}
@@ -194,11 +194,12 @@ crate fn build_index<'tcx>(krate: &clean::Crate, cache: &mut Cache, tcx: TyCtxt<
194
194
crate fn get_index_search_type < ' tcx > (
195
195
item : & clean:: Item ,
196
196
tcx : TyCtxt < ' tcx > ,
197
+ cache : & Cache ,
197
198
) -> Option < IndexItemFunctionType > {
198
199
let ( mut inputs, mut output) = match * item. kind {
199
- clean:: FunctionItem ( ref f) => get_all_types ( & f. generics , & f. decl , tcx) ,
200
- clean:: MethodItem ( ref m, _) => get_all_types ( & m. generics , & m. decl , tcx) ,
201
- clean:: TyMethodItem ( ref m) => get_all_types ( & m. generics , & m. decl , tcx) ,
200
+ clean:: FunctionItem ( ref f) => get_all_types ( & f. generics , & f. decl , tcx, cache ) ,
201
+ clean:: MethodItem ( ref m, _) => get_all_types ( & m. generics , & m. decl , tcx, cache ) ,
202
+ clean:: TyMethodItem ( ref m) => get_all_types ( & m. generics , & m. decl , tcx, cache ) ,
202
203
_ => return None ,
203
204
} ;
204
205
@@ -254,12 +255,14 @@ crate fn get_real_types<'tcx>(
254
255
tcx : TyCtxt < ' tcx > ,
255
256
recurse : usize ,
256
257
res : & mut Vec < TypeWithKind > ,
258
+ cache : & Cache ,
257
259
) {
258
260
fn insert_ty (
259
261
res : & mut Vec < TypeWithKind > ,
260
262
tcx : TyCtxt < ' _ > ,
261
263
ty : Type ,
262
264
mut generics : Vec < TypeWithKind > ,
265
+ _cache : & Cache ,
263
266
) {
264
267
let is_full_generic = ty. is_full_generic ( ) ;
265
268
@@ -350,23 +353,30 @@ crate fn get_real_types<'tcx>(
350
353
continue ;
351
354
}
352
355
if let Some ( ty) = x. get_type ( ) {
353
- get_real_types ( generics, & ty, tcx, recurse + 1 , & mut ty_generics) ;
356
+ get_real_types (
357
+ generics,
358
+ & ty,
359
+ tcx,
360
+ recurse + 1 ,
361
+ & mut ty_generics,
362
+ cache,
363
+ ) ;
354
364
}
355
365
}
356
366
}
357
367
}
358
- insert_ty ( res, tcx, arg. clone ( ) , ty_generics) ;
368
+ insert_ty ( res, tcx, arg. clone ( ) , ty_generics, cache ) ;
359
369
}
360
370
// Otherwise we check if the trait bounds are "inlined" like `T: Option<u32>`...
361
371
if let Some ( bound) = generics. params . iter ( ) . find ( |g| g. is_type ( ) && g. name == arg_s) {
362
372
let mut ty_generics = Vec :: new ( ) ;
363
373
for bound in bound. get_bounds ( ) . unwrap_or ( & [ ] ) {
364
374
if let Some ( path) = bound. get_trait_path ( ) {
365
375
let ty = Type :: ResolvedPath { did : path. def_id ( ) , path } ;
366
- get_real_types ( generics, & ty, tcx, recurse + 1 , & mut ty_generics) ;
376
+ get_real_types ( generics, & ty, tcx, recurse + 1 , & mut ty_generics, cache ) ;
367
377
}
368
378
}
369
- insert_ty ( res, tcx, arg. clone ( ) , ty_generics) ;
379
+ insert_ty ( res, tcx, arg. clone ( ) , ty_generics, cache ) ;
370
380
}
371
381
} else {
372
382
// This is not a type parameter. So for example if we have `T, U: Option<T>`, and we're
@@ -377,10 +387,10 @@ crate fn get_real_types<'tcx>(
377
387
let mut ty_generics = Vec :: new ( ) ;
378
388
if let Some ( arg_generics) = arg. generics ( ) {
379
389
for gen in arg_generics. iter ( ) {
380
- get_real_types ( generics, gen, tcx, recurse + 1 , & mut ty_generics) ;
390
+ get_real_types ( generics, gen, tcx, recurse + 1 , & mut ty_generics, cache ) ;
381
391
}
382
392
}
383
- insert_ty ( res, tcx, arg. clone ( ) , ty_generics) ;
393
+ insert_ty ( res, tcx, arg. clone ( ) , ty_generics, cache ) ;
384
394
}
385
395
}
386
396
@@ -392,6 +402,7 @@ crate fn get_all_types<'tcx>(
392
402
generics : & Generics ,
393
403
decl : & FnDecl ,
394
404
tcx : TyCtxt < ' tcx > ,
405
+ cache : & Cache ,
395
406
) -> ( Vec < TypeWithKind > , Vec < TypeWithKind > ) {
396
407
let mut all_types = Vec :: new ( ) ;
397
408
for arg in decl. inputs . values . iter ( ) {
@@ -401,7 +412,7 @@ crate fn get_all_types<'tcx>(
401
412
// FIXME: performance wise, it'd be much better to move `args` declaration outside of the
402
413
// loop and replace this line with `args.clear()`.
403
414
let mut args = Vec :: new ( ) ;
404
- get_real_types ( generics, & arg. type_ , tcx, 0 , & mut args) ;
415
+ get_real_types ( generics, & arg. type_ , tcx, 0 , & mut args, cache ) ;
405
416
if !args. is_empty ( ) {
406
417
// FIXME: once back to performance improvements, replace this line with:
407
418
// `all_types.extend(args.drain(..));`.
@@ -417,7 +428,7 @@ crate fn get_all_types<'tcx>(
417
428
let mut ret_types = Vec :: new ( ) ;
418
429
match decl. output {
419
430
FnRetTy :: Return ( ref return_type) => {
420
- get_real_types ( generics, return_type, tcx, 0 , & mut ret_types) ;
431
+ get_real_types ( generics, return_type, tcx, 0 , & mut ret_types, cache ) ;
421
432
if ret_types. is_empty ( ) {
422
433
if let Some ( kind) =
423
434
return_type. def_id_no_primitives ( ) . map ( |did| tcx. def_kind ( did) . into ( ) )
0 commit comments