@@ -442,13 +442,13 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> {
442
442
}
443
443
444
444
fn add_item_to_search_index ( tcx : TyCtxt < ' _ > , cache : & mut Cache , item : & clean:: Item , name : Symbol ) {
445
- let ( parent, is_inherent_impl_item ) = match * item. kind {
446
- clean:: StrippedItem ( ..) => ( ( None , None ) , false ) ,
445
+ let ( parent, is_impl_child ) = match * item. kind {
446
+ clean:: StrippedItem ( ..) => return ,
447
447
clean:: AssocConstItem ( ..) | clean:: AssocTypeItem ( ..)
448
448
if cache. parent_stack . last ( ) . is_some_and ( |parent| parent. is_trait_impl ( ) ) =>
449
449
{
450
450
// skip associated items in trait impls
451
- ( ( None , None ) , false )
451
+ return ;
452
452
}
453
453
clean:: TyMethodItem ( ..)
454
454
| clean:: TyAssocConstItem ( ..)
@@ -469,39 +469,35 @@ fn add_item_to_search_index(tcx: TyCtxt<'_>, cache: &mut Cache, item: &clean::It
469
469
false ,
470
470
) ,
471
471
clean:: MethodItem ( ..) | clean:: AssocConstItem ( ..) | clean:: AssocTypeItem ( ..) => {
472
- if cache. parent_stack . is_empty ( ) {
473
- ( ( None , None ) , false )
474
- } else {
475
- let last = cache. parent_stack . last ( ) . expect ( "parent_stack is empty 2" ) ;
476
- let did = match & * last {
477
- ParentStackItem :: Impl {
478
- // impl Trait for &T { fn method(self); }
479
- //
480
- // When generating a function index with the above shape, we want it
481
- // associated with `T`, not with the primitive reference type. It should
482
- // show up as `T::method`, rather than `reference::method`, in the search
483
- // results page.
484
- for_ : clean:: Type :: BorrowedRef { type_, .. } ,
485
- ..
486
- } => type_. def_id ( & cache) ,
487
- ParentStackItem :: Impl { for_, .. } => for_. def_id ( & cache) ,
488
- ParentStackItem :: Type ( item_id) => item_id. as_def_id ( ) ,
489
- } ;
490
- let path = did
491
- . and_then ( |did| cache. paths . get ( & did) )
492
- // The current stack not necessarily has correlation
493
- // for where the type was defined. On the other
494
- // hand, `paths` always has the right
495
- // information if present.
496
- . map ( |( fqp, _) | & fqp[ ..fqp. len ( ) - 1 ] ) ;
497
- ( ( did, path) , true )
498
- }
472
+ let last = cache. parent_stack . last ( ) . expect ( "parent_stack is empty 2" ) ;
473
+ let did = match & * last {
474
+ ParentStackItem :: Impl {
475
+ // impl Trait for &T { fn method(self); }
476
+ //
477
+ // When generating a function index with the above shape, we want it
478
+ // associated with `T`, not with the primitive reference type. It should
479
+ // show up as `T::method`, rather than `reference::method`, in the search
480
+ // results page.
481
+ for_ : clean:: Type :: BorrowedRef { type_, .. } ,
482
+ ..
483
+ } => type_. def_id ( & cache) ,
484
+ ParentStackItem :: Impl { for_, .. } => for_. def_id ( & cache) ,
485
+ ParentStackItem :: Type ( item_id) => item_id. as_def_id ( ) ,
486
+ } ;
487
+ let path = did
488
+ . and_then ( |did| cache. paths . get ( & did) )
489
+ // The current stack not necessarily has correlation
490
+ // for where the type was defined. On the other
491
+ // hand, `paths` always has the right
492
+ // information if present.
493
+ . map ( |( fqp, _) | & fqp[ ..fqp. len ( ) - 1 ] ) ;
494
+ ( ( did, path) , true )
499
495
}
500
496
_ => ( ( None , Some ( & * cache. stack ) ) , false ) ,
501
497
} ;
502
498
503
499
match parent {
504
- ( parent, Some ( path) ) if is_inherent_impl_item || !cache. stripped_mod => {
500
+ ( parent, Some ( path) ) if is_impl_child || !cache. stripped_mod => {
505
501
debug_assert ! ( !item. is_stripped( ) ) ;
506
502
507
503
// A crate has a module at its root, containing all items,
@@ -553,7 +549,7 @@ fn add_item_to_search_index(tcx: TyCtxt<'_>, cache: &mut Cache, item: &clean::It
553
549
} ) ;
554
550
}
555
551
}
556
- ( Some ( parent) , None ) if is_inherent_impl_item => {
552
+ ( Some ( parent) , None ) if is_impl_child => {
557
553
// We have a parent, but we don't know where they're
558
554
// defined yet. Wait for later to index this item.
559
555
let impl_generics = clean_impl_generics ( cache. parent_stack . last ( ) ) ;
0 commit comments