@@ -42,7 +42,7 @@ crate fn build_index<'tcx>(krate: &clean::Crate, cache: &mut Cache, tcx: TyCtxt<
4242 desc,
4343 parent : Some ( did) ,
4444 parent_idx : None ,
45- search_type : get_index_search_type ( item, tcx) ,
45+ search_type : get_index_search_type ( item, tcx, cache ) ,
4646 aliases : item. attrs . get_doc_aliases ( ) ,
4747 } ) ;
4848 }
@@ -194,11 +194,12 @@ crate fn build_index<'tcx>(krate: &clean::Crate, cache: &mut Cache, tcx: TyCtxt<
194194crate fn get_index_search_type < ' tcx > (
195195 item : & clean:: Item ,
196196 tcx : TyCtxt < ' tcx > ,
197+ cache : & Cache ,
197198) -> Option < IndexItemFunctionType > {
198199 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 ) ,
202203 _ => return None ,
203204 } ;
204205
@@ -254,12 +255,14 @@ crate fn get_real_types<'tcx>(
254255 tcx : TyCtxt < ' tcx > ,
255256 recurse : usize ,
256257 res : & mut Vec < TypeWithKind > ,
258+ cache : & Cache ,
257259) {
258260 fn insert_ty (
259261 res : & mut Vec < TypeWithKind > ,
260262 tcx : TyCtxt < ' _ > ,
261263 ty : Type ,
262264 mut generics : Vec < TypeWithKind > ,
265+ _cache : & Cache ,
263266 ) {
264267 let is_full_generic = ty. is_full_generic ( ) ;
265268
@@ -350,23 +353,30 @@ crate fn get_real_types<'tcx>(
350353 continue ;
351354 }
352355 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+ ) ;
354364 }
355365 }
356366 }
357367 }
358- insert_ty ( res, tcx, arg. clone ( ) , ty_generics) ;
368+ insert_ty ( res, tcx, arg. clone ( ) , ty_generics, cache ) ;
359369 }
360370 // Otherwise we check if the trait bounds are "inlined" like `T: Option<u32>`...
361371 if let Some ( bound) = generics. params . iter ( ) . find ( |g| g. is_type ( ) && g. name == arg_s) {
362372 let mut ty_generics = Vec :: new ( ) ;
363373 for bound in bound. get_bounds ( ) . unwrap_or ( & [ ] ) {
364374 if let Some ( path) = bound. get_trait_path ( ) {
365375 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 ) ;
367377 }
368378 }
369- insert_ty ( res, tcx, arg. clone ( ) , ty_generics) ;
379+ insert_ty ( res, tcx, arg. clone ( ) , ty_generics, cache ) ;
370380 }
371381 } else {
372382 // 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>(
377387 let mut ty_generics = Vec :: new ( ) ;
378388 if let Some ( arg_generics) = arg. generics ( ) {
379389 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 ) ;
381391 }
382392 }
383- insert_ty ( res, tcx, arg. clone ( ) , ty_generics) ;
393+ insert_ty ( res, tcx, arg. clone ( ) , ty_generics, cache ) ;
384394 }
385395}
386396
@@ -392,6 +402,7 @@ crate fn get_all_types<'tcx>(
392402 generics : & Generics ,
393403 decl : & FnDecl ,
394404 tcx : TyCtxt < ' tcx > ,
405+ cache : & Cache ,
395406) -> ( Vec < TypeWithKind > , Vec < TypeWithKind > ) {
396407 let mut all_types = Vec :: new ( ) ;
397408 for arg in decl. inputs . values . iter ( ) {
@@ -401,7 +412,7 @@ crate fn get_all_types<'tcx>(
401412 // FIXME: performance wise, it'd be much better to move `args` declaration outside of the
402413 // loop and replace this line with `args.clear()`.
403414 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 ) ;
405416 if !args. is_empty ( ) {
406417 // FIXME: once back to performance improvements, replace this line with:
407418 // `all_types.extend(args.drain(..));`.
@@ -417,7 +428,7 @@ crate fn get_all_types<'tcx>(
417428 let mut ret_types = Vec :: new ( ) ;
418429 match decl. output {
419430 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 ) ;
421432 if ret_types. is_empty ( ) {
422433 if let Some ( kind) =
423434 return_type. def_id_no_primitives ( ) . map ( |did| tcx. def_kind ( did) . into ( ) )
0 commit comments