@@ -442,7 +442,7 @@ 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_impl_child) = match * item. kind {
445
+ let ( ( parent_did , parent_path ) , is_impl_child) = match * item. kind {
446
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 ( ) ) =>
@@ -496,77 +496,77 @@ fn add_item_to_search_index(tcx: TyCtxt<'_>, cache: &mut Cache, item: &clean::It
496
496
_ => ( ( None , Some ( & * cache. stack ) ) , false ) ,
497
497
} ;
498
498
499
- match parent {
500
- ( parent, Some ( path) ) if is_impl_child || !cache. stripped_mod => {
501
- debug_assert ! ( !item. is_stripped( ) ) ;
502
-
503
- // A crate has a module at its root, containing all items,
504
- // which should not be indexed. The crate-item itself is
505
- // inserted later on when serializing the search-index.
506
- if item. item_id . as_def_id ( ) . is_some_and ( |idx| !idx. is_crate_root ( ) )
507
- && let ty = item. type_ ( )
508
- && ( ty != ItemType :: StructField || u16:: from_str_radix ( name. as_str ( ) , 10 ) . is_err ( ) )
499
+ if let Some ( parent_did) = parent_did
500
+ && parent_path. is_none ( )
501
+ && is_impl_child
502
+ {
503
+ // We have a parent, but we don't know where they're
504
+ // defined yet. Wait for later to index this item.
505
+ let impl_generics = clean_impl_generics ( cache. parent_stack . last ( ) ) ;
506
+ cache. orphan_impl_items . push ( OrphanImplItem {
507
+ parent : parent_did,
508
+ item : item. clone ( ) ,
509
+ impl_generics,
510
+ impl_id : if let Some ( ParentStackItem :: Impl { item_id, .. } ) = cache. parent_stack . last ( )
509
511
{
510
- let desc = short_markdown_summary ( & item. doc_value ( ) , & item. link_names ( cache) ) ;
511
- // For searching purposes, a re-export is a duplicate if:
512
- //
513
- // - It's either an inline, or a true re-export
514
- // - It's got the same name
515
- // - Both of them have the same exact path
516
- let defid = ( match & * item. kind {
517
- & clean:: ItemKind :: ImportItem ( ref import) => import. source . did ,
518
- _ => None ,
519
- } )
520
- . or_else ( || item. item_id . as_def_id ( ) ) ;
521
- // In case this is a field from a tuple struct, we don't add it into
522
- // the search index because its name is something like "0", which is
523
- // not useful for rustdoc search.
524
- cache. search_index . push ( IndexItem {
525
- ty,
526
- defid,
527
- name,
528
- path : join_with_double_colon ( path) ,
529
- desc,
530
- parent,
531
- parent_idx : None ,
532
- exact_path : None ,
533
- impl_id : if let Some ( ParentStackItem :: Impl { item_id, .. } ) =
534
- cache. parent_stack . last ( )
535
- {
536
- item_id. as_def_id ( )
537
- } else {
538
- None
539
- } ,
540
- search_type : get_function_type_for_search (
541
- & item,
542
- tcx,
543
- clean_impl_generics ( cache. parent_stack . last ( ) ) . as_ref ( ) ,
544
- parent,
545
- cache,
546
- ) ,
547
- aliases : item. attrs . get_doc_aliases ( ) ,
548
- deprecation : item. deprecation ( tcx) ,
549
- } ) ;
550
- }
551
- }
552
- ( Some ( parent) , None ) if is_impl_child => {
553
- // We have a parent, but we don't know where they're
554
- // defined yet. Wait for later to index this item.
555
- let impl_generics = clean_impl_generics ( cache. parent_stack . last ( ) ) ;
556
- cache. orphan_impl_items . push ( OrphanImplItem {
557
- parent,
558
- item : item. clone ( ) ,
559
- impl_generics,
512
+ item_id. as_def_id ( )
513
+ } else {
514
+ None
515
+ } ,
516
+ } ) ;
517
+ } else if let Some ( path) = parent_path
518
+ && ( is_impl_child || !cache. stripped_mod )
519
+ {
520
+ debug_assert ! ( !item. is_stripped( ) ) ;
521
+
522
+ // A crate has a module at its root, containing all items,
523
+ // which should not be indexed. The crate-item itself is
524
+ // inserted later on when serializing the search-index.
525
+ if item. item_id . as_def_id ( ) . is_some_and ( |idx| !idx. is_crate_root ( ) )
526
+ && let ty = item. type_ ( )
527
+ && ( ty != ItemType :: StructField || u16:: from_str_radix ( name. as_str ( ) , 10 ) . is_err ( ) )
528
+ {
529
+ let desc = short_markdown_summary ( & item. doc_value ( ) , & item. link_names ( cache) ) ;
530
+ // For searching purposes, a re-export is a duplicate if:
531
+ //
532
+ // - It's either an inline, or a true re-export
533
+ // - It's got the same name
534
+ // - Both of them have the same exact path
535
+ let defid = ( match & * item. kind {
536
+ & clean:: ItemKind :: ImportItem ( ref import) => import. source . did ,
537
+ _ => None ,
538
+ } )
539
+ . or_else ( || item. item_id . as_def_id ( ) ) ;
540
+ // In case this is a field from a tuple struct, we don't add it into
541
+ // the search index because its name is something like "0", which is
542
+ // not useful for rustdoc search.
543
+ cache. search_index . push ( IndexItem {
544
+ ty,
545
+ defid,
546
+ name,
547
+ path : join_with_double_colon ( path) ,
548
+ desc,
549
+ parent : parent_did,
550
+ parent_idx : None ,
551
+ exact_path : None ,
560
552
impl_id : if let Some ( ParentStackItem :: Impl { item_id, .. } ) =
561
553
cache. parent_stack . last ( )
562
554
{
563
555
item_id. as_def_id ( )
564
556
} else {
565
557
None
566
558
} ,
559
+ search_type : get_function_type_for_search (
560
+ & item,
561
+ tcx,
562
+ clean_impl_generics ( cache. parent_stack . last ( ) ) . as_ref ( ) ,
563
+ parent_did,
564
+ cache,
565
+ ) ,
566
+ aliases : item. attrs . get_doc_aliases ( ) ,
567
+ deprecation : item. deprecation ( tcx) ,
567
568
} ) ;
568
569
}
569
- _ => { }
570
570
}
571
571
}
572
572
0 commit comments