@@ -43,7 +43,7 @@ crate fn build_index<'tcx>(krate: &clean::Crate, cache: &mut Cache, tcx: TyCtxt<
4343 desc,
4444 parent : Some ( did) ,
4545 parent_idx : None ,
46- search_type : get_index_search_type ( item, tcx) ,
46+ search_type : get_index_search_type ( item, tcx, cache ) ,
4747 aliases : item. attrs . get_doc_aliases ( ) ,
4848 } ) ;
4949 }
@@ -191,11 +191,12 @@ crate fn build_index<'tcx>(krate: &clean::Crate, cache: &mut Cache, tcx: TyCtxt<
191191crate fn get_index_search_type < ' tcx > (
192192 item : & clean:: Item ,
193193 tcx : TyCtxt < ' tcx > ,
194+ cache : & Cache ,
194195) -> Option < IndexItemFunctionType > {
195196 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 ) ,
199200 _ => return None ,
200201 } ;
201202
@@ -249,12 +250,14 @@ crate fn get_real_types<'tcx>(
249250 tcx : TyCtxt < ' tcx > ,
250251 recurse : usize ,
251252 res : & mut Vec < TypeWithKind > ,
253+ cache : & Cache ,
252254) {
253255 fn insert_ty (
254256 res : & mut Vec < TypeWithKind > ,
255257 tcx : TyCtxt < ' _ > ,
256258 ty : Type ,
257259 mut generics : Vec < TypeWithKind > ,
260+ cache : & Cache ,
258261 ) {
259262 let is_full_generic = ty. is_full_generic ( ) ;
260263
@@ -306,7 +309,7 @@ crate fn get_real_types<'tcx>(
306309 // We remove the name of the full generic because we have no use for it.
307310 index_ty. name = Some ( String :: new ( ) ) ;
308311 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 ( ) ) {
310313 res. push ( TypeWithKind :: from ( ( index_ty, kind) ) ) ;
311314 } else if ty. is_primitive ( ) {
312315 // This is a primitive, let's store it as such.
@@ -321,9 +324,7 @@ crate fn get_real_types<'tcx>(
321324
322325 if let Type :: Generic ( arg_s) = * arg {
323326 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) ,
327328 _ => false ,
328329 } ) {
329330 let mut ty_generics = Vec :: new ( ) ;
@@ -335,31 +336,38 @@ crate fn get_real_types<'tcx>(
335336 continue ;
336337 }
337338 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+ ) ;
339347 }
340348 }
341349 }
342350 }
343- insert_ty ( res, tcx, arg. clone ( ) , ty_generics) ;
351+ insert_ty ( res, tcx, arg. clone ( ) , ty_generics, cache ) ;
344352 }
345353 if let Some ( bound) = generics. params . iter ( ) . find ( |g| g. is_type ( ) && g. name == arg_s) {
346354 let mut ty_generics = Vec :: new ( ) ;
347355 for bound in bound. get_bounds ( ) . unwrap_or ( & [ ] ) {
348356 if let Some ( path) = bound. get_trait_path ( ) {
349357 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 ) ;
351359 }
352360 }
353- insert_ty ( res, tcx, arg. clone ( ) , ty_generics) ;
361+ insert_ty ( res, tcx, arg. clone ( ) , ty_generics, cache ) ;
354362 }
355363 } else {
356364 let mut ty_generics = Vec :: new ( ) ;
357365 if let Some ( arg_generics) = arg. generics ( ) {
358366 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 ) ;
360368 }
361369 }
362- insert_ty ( res, tcx, arg. clone ( ) , ty_generics) ;
370+ insert_ty ( res, tcx, arg. clone ( ) , ty_generics, cache ) ;
363371 }
364372}
365373
@@ -371,6 +379,7 @@ crate fn get_all_types<'tcx>(
371379 generics : & Generics ,
372380 decl : & FnDecl ,
373381 tcx : TyCtxt < ' tcx > ,
382+ cache : & Cache ,
374383) -> ( Vec < TypeWithKind > , Vec < TypeWithKind > ) {
375384 let mut all_types = Vec :: new ( ) ;
376385 for arg in decl. inputs . values . iter ( ) {
@@ -380,14 +389,13 @@ crate fn get_all_types<'tcx>(
380389 // FIXME: performance wise, it'd be much better to move `args` declaration outside of the
381390 // loop and replace this line with `args.clear()`.
382391 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 ) ;
384393 if !args. is_empty ( ) {
385394 // FIXME: once back to performance improvements, replace this line with:
386395 // `all_types.extend(args.drain(..));`.
387396 all_types. extend ( args) ;
388397 } 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 ( ) ) {
391399 all_types. push ( TypeWithKind :: from ( ( get_index_type ( & arg. type_ , vec ! [ ] ) , kind) ) ) ;
392400 }
393401 }
@@ -396,11 +404,9 @@ crate fn get_all_types<'tcx>(
396404 let mut ret_types = Vec :: new ( ) ;
397405 match decl. output {
398406 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 ) ;
400408 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 ( ) ) {
404410 ret_types. push ( TypeWithKind :: from ( ( get_index_type ( return_type, vec ! [ ] ) , kind) ) ) ;
405411 }
406412 }
0 commit comments