@@ -48,7 +48,6 @@ use crate::html::render::{self, IndexItem, IndexItemFunctionType, RenderType, Re
48
48
pub ( crate ) struct SerializedSearchIndex {
49
49
pub ( crate ) index : String ,
50
50
pub ( crate ) desc : Vec < ( usize , String ) > ,
51
- pub ( crate ) param_names : String ,
52
51
}
53
52
54
53
const DESC_INDEX_SHARD_LEN : usize = 128 * 1024 ;
@@ -621,9 +620,25 @@ pub(crate) fn build_index<'tcx>(
621
620
full_paths. push ( ( * index, path) ) ;
622
621
}
623
622
623
+ let param_names: Vec < ( usize , String ) > = {
624
+ let mut prev = Vec :: new ( ) ;
625
+ let mut result = Vec :: new ( ) ;
626
+ for ( index, item) in self . items . iter ( ) . enumerate ( ) {
627
+ if let Some ( ty) = & item. search_type
628
+ && let my =
629
+ ty. param_names . iter ( ) . map ( |sym| sym. as_str ( ) ) . collect :: < Vec < _ > > ( )
630
+ && my != prev
631
+ {
632
+ result. push ( ( index, my. join ( "," ) ) ) ;
633
+ prev = my;
634
+ }
635
+ }
636
+ result
637
+ } ;
638
+
624
639
let has_aliases = !self . aliases . is_empty ( ) ;
625
640
let mut crate_data =
626
- serializer. serialize_struct ( "CrateData" , if has_aliases { 9 } else { 8 } ) ?;
641
+ serializer. serialize_struct ( "CrateData" , if has_aliases { 13 } else { 12 } ) ?;
627
642
crate_data. serialize_field ( "t" , & types) ?;
628
643
crate_data. serialize_field ( "n" , & names) ?;
629
644
crate_data. serialize_field ( "q" , & full_paths) ?;
@@ -635,6 +650,7 @@ pub(crate) fn build_index<'tcx>(
635
650
crate_data. serialize_field ( "b" , & self . associated_item_disambiguators ) ?;
636
651
crate_data. serialize_field ( "c" , & bitmap_to_string ( & deprecated) ) ?;
637
652
crate_data. serialize_field ( "e" , & bitmap_to_string ( & self . empty_desc ) ) ?;
653
+ crate_data. serialize_field ( "P" , & param_names) ?;
638
654
if has_aliases {
639
655
crate_data. serialize_field ( "a" , & self . aliases ) ?;
640
656
}
@@ -681,23 +697,6 @@ pub(crate) fn build_index<'tcx>(
681
697
desc. iter( ) . map( |( len, _) | * len) . sum:: <usize >( ) + empty_desc. len( )
682
698
) ;
683
699
684
- let param_names = {
685
- let result: Vec < Vec < & str > > = crate_items
686
- . iter ( )
687
- . map ( |item| match & item. search_type {
688
- Some ( ty) => ty. param_names . iter ( ) . map ( |sym| sym. as_str ( ) ) . collect ( ) ,
689
- None => Vec :: new ( ) ,
690
- } )
691
- . collect ( ) ;
692
- serde_json:: to_string ( & result)
693
- . expect ( "failed serde conversion" )
694
- // All these `replace` calls are because we have to go through JS string for JSON content.
695
- . replace ( '\\' , r"\\" )
696
- . replace ( '\'' , r"\'" )
697
- // We need to escape double quotes for the JSON.
698
- . replace ( "\\ \" " , "\\ \\ \" " )
699
- } ;
700
-
701
700
// The index, which is actually used to search, is JSON
702
701
// It uses `JSON.parse(..)` to actually load, since JSON
703
702
// parses faster than the full JavaScript syntax.
@@ -719,7 +718,7 @@ pub(crate) fn build_index<'tcx>(
719
718
// We need to escape double quotes for the JSON.
720
719
. replace( "\\ \" " , "\\ \\ \" " )
721
720
) ;
722
- SerializedSearchIndex { index, desc, param_names }
721
+ SerializedSearchIndex { index, desc }
723
722
}
724
723
725
724
pub ( crate ) fn get_function_type_for_search < ' tcx > (
0 commit comments