@@ -315,6 +315,29 @@ impl SerializedSearchIndex {
315315 let other_entryid_offset = self . names . len ( ) ;
316316 let mut map_other_pathid_to_self_pathid = Vec :: new ( ) ;
317317 let mut skips = FxHashSet :: default ( ) ;
318+
319+ fn remap_entry_data (
320+ other_entry_data : & EntryData ,
321+ map_other_pathid_to_self_pathid : & [ usize ] ,
322+ ) -> EntryData {
323+ EntryData {
324+ parent : other_entry_data
325+ . parent
326+ . map ( |parent| map_other_pathid_to_self_pathid[ parent] )
327+ . clone ( ) ,
328+ module_path : other_entry_data
329+ . module_path
330+ . map ( |path| map_other_pathid_to_self_pathid[ path] )
331+ . clone ( ) ,
332+ exact_module_path : other_entry_data
333+ . exact_module_path
334+ . map ( |exact_path| map_other_pathid_to_self_pathid[ exact_path] )
335+ . clone ( ) ,
336+ krate : map_other_pathid_to_self_pathid[ other_entry_data. krate ] ,
337+ ..other_entry_data. clone ( )
338+ }
339+ }
340+
318341 for ( other_pathid, other_path_data) in other. path_data . iter ( ) . enumerate ( ) {
319342 if let Some ( other_path_data) = other_path_data {
320343 let name = Symbol :: intern ( & other. names [ other_pathid] ) ;
@@ -439,87 +462,72 @@ impl SerializedSearchIndex {
439462 }
440463 }
441464 for other_entryid in 0 ..other. names . len ( ) {
442- if skips. contains ( & other_entryid) {
443- // we push tombstone entries to keep the IDs lined up
444- self . push ( String :: new ( ) , None , None , String :: new ( ) , None , None , None ) ;
445- } else {
446- self . push (
447- other. names [ other_entryid] . clone ( ) ,
448- other. path_data [ other_entryid] . clone ( ) ,
449- other. entry_data [ other_entryid] . as_ref ( ) . map ( |other_entry_data| EntryData {
450- parent : other_entry_data
451- . parent
452- . map ( |parent| map_other_pathid_to_self_pathid[ parent] )
453- . clone ( ) ,
454- module_path : other_entry_data
455- . module_path
456- . map ( |path| map_other_pathid_to_self_pathid[ path] )
457- . clone ( ) ,
458- exact_module_path : other_entry_data
459- . exact_module_path
460- . map ( |exact_path| map_other_pathid_to_self_pathid[ exact_path] )
461- . clone ( ) ,
462- krate : map_other_pathid_to_self_pathid[ other_entry_data. krate ] ,
463- ..other_entry_data. clone ( )
464- } ) ,
465- other. descs [ other_entryid] . clone ( ) ,
466- other. function_data [ other_entryid] . clone ( ) . map ( |mut func| {
467- fn map_fn_sig_item (
468- map_other_pathid_to_self_pathid : & Vec < usize > ,
469- ty : & mut RenderType ,
470- ) {
471- match ty. id {
472- None => { }
473- Some ( RenderTypeId :: Index ( generic) ) if generic < 0 => { }
474- Some ( RenderTypeId :: Index ( id) ) => {
475- let id = usize:: try_from ( id) . unwrap ( ) ;
476- let id = map_other_pathid_to_self_pathid[ id] ;
477- assert ! ( id != !0 ) ;
478- ty. id = Some ( RenderTypeId :: Index ( isize:: try_from ( id) . unwrap ( ) ) ) ;
479- }
480- _ => unreachable ! ( ) ,
465+ self . push (
466+ other. names [ other_entryid] . clone ( ) ,
467+ if skips. contains ( & other_entryid) {
468+ None
469+ } else {
470+ other. path_data [ other_entryid] . clone ( )
471+ } ,
472+ other. entry_data [ other_entryid] . as_ref ( ) . map ( |other_entry_data| {
473+ remap_entry_data ( other_entry_data, & map_other_pathid_to_self_pathid)
474+ } ) ,
475+ other. descs [ other_entryid] . clone ( ) ,
476+ other. function_data [ other_entryid] . clone ( ) . map ( |mut func| {
477+ fn map_fn_sig_item (
478+ map_other_pathid_to_self_pathid : & Vec < usize > ,
479+ ty : & mut RenderType ,
480+ ) {
481+ match ty. id {
482+ None => { }
483+ Some ( RenderTypeId :: Index ( generic) ) if generic < 0 => { }
484+ Some ( RenderTypeId :: Index ( id) ) => {
485+ let id = usize:: try_from ( id) . unwrap ( ) ;
486+ let id = map_other_pathid_to_self_pathid[ id] ;
487+ assert ! ( id != !0 ) ;
488+ ty. id = Some ( RenderTypeId :: Index ( isize:: try_from ( id) . unwrap ( ) ) ) ;
481489 }
482- if let Some ( generics) = & mut ty. generics {
483- for generic in generics {
484- map_fn_sig_item ( map_other_pathid_to_self_pathid, generic) ;
485- }
490+ _ => unreachable ! ( ) ,
491+ }
492+ if let Some ( generics) = & mut ty. generics {
493+ for generic in generics {
494+ map_fn_sig_item ( map_other_pathid_to_self_pathid, generic) ;
486495 }
487- if let Some ( bindings) = & mut ty. bindings {
488- for ( param, constraints) in bindings {
489- * param = match * param {
490- param @ RenderTypeId :: Index ( generic) if generic < 0 => {
491- param
492- }
493- RenderTypeId :: Index ( id) => {
494- let id = usize:: try_from ( id) . unwrap ( ) ;
495- let id = map_other_pathid_to_self_pathid[ id] ;
496- assert ! ( id != !0 ) ;
497- RenderTypeId :: Index ( isize:: try_from ( id) . unwrap ( ) )
498- }
499- _ => unreachable ! ( ) ,
500- } ;
501- for constraint in constraints {
502- map_fn_sig_item (
503- map_other_pathid_to_self_pathid,
504- constraint,
505- ) ;
496+ }
497+ if let Some ( bindings) = & mut ty. bindings {
498+ for ( param, constraints) in bindings {
499+ * param = match * param {
500+ param @ RenderTypeId :: Index ( generic) if generic < 0 => param,
501+ RenderTypeId :: Index ( id) => {
502+ let id = usize:: try_from ( id) . unwrap ( ) ;
503+ let id = map_other_pathid_to_self_pathid[ id] ;
504+ assert ! ( id != !0 ) ;
505+ RenderTypeId :: Index ( isize:: try_from ( id) . unwrap ( ) )
506506 }
507+ _ => unreachable ! ( ) ,
508+ } ;
509+ for constraint in constraints {
510+ map_fn_sig_item ( map_other_pathid_to_self_pathid, constraint) ;
507511 }
508512 }
509513 }
510- for input in & mut func . inputs {
511- map_fn_sig_item ( & map_other_pathid_to_self_pathid , input ) ;
512- }
513- for output in & mut func . output {
514- map_fn_sig_item ( & map_other_pathid_to_self_pathid , output) ;
515- }
516- for clause in & mut func . where_clause {
517- for entry in clause {
518- map_fn_sig_item ( & map_other_pathid_to_self_pathid , entry ) ;
519- }
514+ }
515+ for input in & mut func . inputs {
516+ map_fn_sig_item ( & map_other_pathid_to_self_pathid , input ) ;
517+ }
518+ for output in & mut func . output {
519+ map_fn_sig_item ( & map_other_pathid_to_self_pathid , output ) ;
520+ }
521+ for clause in & mut func . where_clause {
522+ for entry in clause {
523+ map_fn_sig_item ( & map_other_pathid_to_self_pathid , entry ) ;
520524 }
521- func
522- } ) ,
525+ }
526+ func
527+ } ) ,
528+ if skips. contains ( & other_entryid) {
529+ None
530+ } else {
523531 other. type_data [ other_entryid] . as_ref ( ) . map ( |type_data| TypeData {
524532 inverted_function_inputs_index : type_data
525533 . inverted_function_inputs_index
@@ -556,11 +564,11 @@ impl SerializedSearchIndex {
556564 } )
557565 . collect ( ) ,
558566 search_unbox : type_data. search_unbox ,
559- } ) ,
560- other . alias_pointers [ other_entryid ]
561- . map ( |alias_pointer| alias_pointer + other_entryid_offset ) ,
562- ) ;
563- }
567+ } )
568+ } ,
569+ other . alias_pointers [ other_entryid ]
570+ . map ( |alias_pointer| alias_pointer + other_entryid_offset ) ,
571+ ) ;
564572 }
565573 if other. generic_inverted_index . len ( ) > self . generic_inverted_index . len ( ) {
566574 self . generic_inverted_index . resize ( other. generic_inverted_index . len ( ) , Vec :: new ( ) ) ;
0 commit comments