@@ -610,6 +610,7 @@ impl SerializedSearchIndex {
610610 module_path,
611611 exact_module_path,
612612 parent,
613+ trait_parent,
613614 deprecated,
614615 associated_item_disambiguator,
615616 } | EntryData {
@@ -619,6 +620,7 @@ impl SerializedSearchIndex {
619620 exact_module_path : exact_module_path
620621 . and_then ( |path_id| map. get ( & path_id) . copied ( ) ) ,
621622 parent : parent. and_then ( |path_id| map. get ( & path_id) . copied ( ) ) ,
623+ trait_parent : trait_parent. and_then ( |path_id| map. get ( & path_id) . copied ( ) ) ,
622624 deprecated : * deprecated,
623625 associated_item_disambiguator : associated_item_disambiguator. clone ( ) ,
624626 } ,
@@ -900,6 +902,7 @@ struct EntryData {
900902 module_path : Option < usize > ,
901903 exact_module_path : Option < usize > ,
902904 parent : Option < usize > ,
905+ trait_parent : Option < usize > ,
903906 deprecated : bool ,
904907 associated_item_disambiguator : Option < String > ,
905908}
@@ -915,6 +918,7 @@ impl Serialize for EntryData {
915918 seq. serialize_element ( & self . module_path . map ( |id| id + 1 ) . unwrap_or ( 0 ) ) ?;
916919 seq. serialize_element ( & self . exact_module_path . map ( |id| id + 1 ) . unwrap_or ( 0 ) ) ?;
917920 seq. serialize_element ( & self . parent . map ( |id| id + 1 ) . unwrap_or ( 0 ) ) ?;
921+ seq. serialize_element ( & self . trait_parent . map ( |id| id + 1 ) . unwrap_or ( 0 ) ) ?;
918922 seq. serialize_element ( & if self . deprecated { 1 } else { 0 } ) ?;
919923 if let Some ( disambig) = & self . associated_item_disambiguator {
920924 seq. serialize_element ( & disambig) ?;
@@ -946,6 +950,9 @@ impl<'de> Deserialize<'de> for EntryData {
946950 . ok_or_else ( || A :: Error :: missing_field ( "exact_module_path" ) ) ?;
947951 let parent: SerializedOptional32 =
948952 v. next_element ( ) ?. ok_or_else ( || A :: Error :: missing_field ( "parent" ) ) ?;
953+ let trait_parent: SerializedOptional32 =
954+ v. next_element ( ) ?. ok_or_else ( || A :: Error :: missing_field ( "trait_parent" ) ) ?;
955+
949956 let deprecated: u32 = v. next_element ( ) ?. unwrap_or ( 0 ) ;
950957 let associated_item_disambiguator: Option < String > = v. next_element ( ) ?;
951958 Ok ( EntryData {
@@ -955,6 +962,7 @@ impl<'de> Deserialize<'de> for EntryData {
955962 exact_module_path : Option :: < i32 > :: from ( exact_module_path)
956963 . map ( |path| path as usize ) ,
957964 parent : Option :: < i32 > :: from ( parent) . map ( |path| path as usize ) ,
965+ trait_parent : Option :: < i32 > :: from ( trait_parent) . map ( |path| path as usize ) ,
958966 deprecated : deprecated != 0 ,
959967 associated_item_disambiguator,
960968 } )
@@ -1305,7 +1313,8 @@ pub(crate) fn build_index(
13051313
13061314 // Attach all orphan items to the type's definition if the type
13071315 // has since been learned.
1308- for & OrphanImplItem { impl_id, parent, ref item, ref impl_generics } in & cache. orphan_impl_items
1316+ for & OrphanImplItem { impl_id, parent, trait_parent, ref item, ref impl_generics } in
1317+ & cache. orphan_impl_items
13091318 {
13101319 if let Some ( ( fqp, _) ) = cache. paths . get ( & parent) {
13111320 let desc = short_markdown_summary ( & item. doc_value ( ) , & item. link_names ( cache) ) ;
@@ -1317,6 +1326,8 @@ pub(crate) fn build_index(
13171326 desc,
13181327 parent : Some ( parent) ,
13191328 parent_idx : None ,
1329+ trait_parent,
1330+ trait_parent_idx : None ,
13201331 exact_module_path : None ,
13211332 impl_id,
13221333 search_type : get_function_type_for_search (
@@ -1421,6 +1432,7 @@ pub(crate) fn build_index(
14211432 module_path : None ,
14221433 exact_module_path : None ,
14231434 parent : None ,
1435+ trait_parent : None ,
14241436 deprecated : false ,
14251437 associated_item_disambiguator : None ,
14261438 } ) ,
@@ -1434,39 +1446,46 @@ pub(crate) fn build_index(
14341446 }
14351447 } ;
14361448
1437- // First, populate associated item parents
1449+ // First, populate associated item parents and trait parents
14381450 let crate_items: Vec < & mut IndexItem > = search_index
14391451 . iter_mut ( )
14401452 . map ( |item| {
1441- item. parent_idx = item. parent . and_then ( |defid| {
1442- cache. paths . get ( & defid) . map ( |& ( ref fqp, ty) | {
1443- let pathid = serialized_index. names . len ( ) ;
1444- match serialized_index. crate_paths_index . entry ( ( ty, fqp. clone ( ) ) ) {
1445- Entry :: Occupied ( entry) => * entry. get ( ) ,
1446- Entry :: Vacant ( entry) => {
1447- entry. insert ( pathid) ;
1448- let ( name, path) = fqp. split_last ( ) . unwrap ( ) ;
1449- serialized_index. push_path (
1450- name. as_str ( ) . to_string ( ) ,
1451- PathData {
1452- ty,
1453- module_path : path. to_vec ( ) ,
1454- exact_module_path : if let Some ( exact_path) =
1455- cache. exact_paths . get ( & defid)
1456- && let Some ( ( name2, exact_path) ) = exact_path. split_last ( )
1457- && name == name2
1458- {
1459- Some ( exact_path. to_vec ( ) )
1460- } else {
1461- None
1453+ let mut defid_to_rowid = |defid, check_external : bool | {
1454+ cache
1455+ . paths
1456+ . get ( & defid)
1457+ . or_else ( || check_external. then ( || cache. external_paths . get ( & defid) ) . flatten ( ) )
1458+ . map ( |& ( ref fqp, ty) | {
1459+ let pathid = serialized_index. names . len ( ) ;
1460+ match serialized_index. crate_paths_index . entry ( ( ty, fqp. clone ( ) ) ) {
1461+ Entry :: Occupied ( entry) => * entry. get ( ) ,
1462+ Entry :: Vacant ( entry) => {
1463+ entry. insert ( pathid) ;
1464+ let ( name, path) = fqp. split_last ( ) . unwrap ( ) ;
1465+ serialized_index. push_path (
1466+ name. as_str ( ) . to_string ( ) ,
1467+ PathData {
1468+ ty,
1469+ module_path : path. to_vec ( ) ,
1470+ exact_module_path : if let Some ( exact_path) =
1471+ cache. exact_paths . get ( & defid)
1472+ && let Some ( ( name2, exact_path) ) =
1473+ exact_path. split_last ( )
1474+ && name == name2
1475+ {
1476+ Some ( exact_path. to_vec ( ) )
1477+ } else {
1478+ None
1479+ } ,
14621480 } ,
1463- } ,
1464- ) ;
1465- usize :: try_from ( pathid ) . unwrap ( )
1481+ ) ;
1482+ usize :: try_from ( pathid ) . unwrap ( )
1483+ }
14661484 }
1467- }
1468- } )
1469- } ) ;
1485+ } )
1486+ } ;
1487+ item. parent_idx = item. parent . and_then ( |p| defid_to_rowid ( p, false ) ) ;
1488+ item. trait_parent_idx = item. trait_parent . and_then ( |p| defid_to_rowid ( p, true ) ) ;
14701489
14711490 if let Some ( defid) = item. defid
14721491 && item. parent_idx . is_none ( )
@@ -1549,6 +1568,7 @@ pub(crate) fn build_index(
15491568 EntryData {
15501569 ty : item. ty ,
15511570 parent : item. parent_idx ,
1571+ trait_parent : item. trait_parent_idx ,
15521572 module_path,
15531573 exact_module_path,
15541574 deprecated : item. deprecation . is_some ( ) ,
0 commit comments