@@ -646,9 +646,25 @@ pub(crate) fn build_index<'tcx>(
646646 full_paths. push ( ( * index, path) ) ;
647647 }
648648
649+ let param_names: Vec < ( usize , String ) > = {
650+ let mut prev = Vec :: new ( ) ;
651+ let mut result = Vec :: new ( ) ;
652+ for ( index, item) in self . items . iter ( ) . enumerate ( ) {
653+ if let Some ( ty) = & item. search_type
654+ && let my =
655+ ty. param_names . iter ( ) . map ( |sym| sym. as_str ( ) ) . collect :: < Vec < _ > > ( )
656+ && my != prev
657+ {
658+ result. push ( ( index, my. join ( "," ) ) ) ;
659+ prev = my;
660+ }
661+ }
662+ result
663+ } ;
664+
649665 let has_aliases = !self . aliases . is_empty ( ) ;
650666 let mut crate_data =
651- serializer. serialize_struct ( "CrateData" , if has_aliases { 9 } else { 8 } ) ?;
667+ serializer. serialize_struct ( "CrateData" , if has_aliases { 13 } else { 12 } ) ?;
652668 crate_data. serialize_field ( "t" , & types) ?;
653669 crate_data. serialize_field ( "n" , & names) ?;
654670 crate_data. serialize_field ( "q" , & full_paths) ?;
@@ -660,6 +676,7 @@ pub(crate) fn build_index<'tcx>(
660676 crate_data. serialize_field ( "b" , & self . associated_item_disambiguators ) ?;
661677 crate_data. serialize_field ( "c" , & bitmap_to_string ( & deprecated) ) ?;
662678 crate_data. serialize_field ( "e" , & bitmap_to_string ( & self . empty_desc ) ) ?;
679+ crate_data. serialize_field ( "P" , & param_names) ?;
663680 if has_aliases {
664681 crate_data. serialize_field ( "a" , & self . aliases ) ?;
665682 }
@@ -758,7 +775,7 @@ pub(crate) fn get_function_type_for_search<'tcx>(
758775 None
759776 }
760777 } ) ;
761- let ( mut inputs, mut output, where_clause) = match item. kind {
778+ let ( mut inputs, mut output, param_names , where_clause) = match item. kind {
762779 clean:: FunctionItem ( ref f) | clean:: MethodItem ( ref f, _) | clean:: TyMethodItem ( ref f) => {
763780 get_fn_inputs_and_outputs ( f, tcx, impl_or_trait_generics, cache)
764781 }
@@ -768,7 +785,7 @@ pub(crate) fn get_function_type_for_search<'tcx>(
768785 inputs. retain ( |a| a. id . is_some ( ) || a. generics . is_some ( ) ) ;
769786 output. retain ( |a| a. id . is_some ( ) || a. generics . is_some ( ) ) ;
770787
771- Some ( IndexItemFunctionType { inputs, output, where_clause } )
788+ Some ( IndexItemFunctionType { inputs, output, where_clause, param_names } )
772789}
773790
774791fn get_index_type (
@@ -1282,7 +1299,7 @@ fn get_fn_inputs_and_outputs<'tcx>(
12821299 tcx : TyCtxt < ' tcx > ,
12831300 impl_or_trait_generics : Option < & ( clean:: Type , clean:: Generics ) > ,
12841301 cache : & Cache ,
1285- ) -> ( Vec < RenderType > , Vec < RenderType > , Vec < Vec < RenderType > > ) {
1302+ ) -> ( Vec < RenderType > , Vec < RenderType > , Vec < Symbol > , Vec < Vec < RenderType > > ) {
12861303 let decl = & func. decl ;
12871304
12881305 let mut rgen: FxHashMap < SimplifiedParam , ( isize , Vec < RenderType > ) > = Default :: default ( ) ;
@@ -1328,7 +1345,21 @@ fn get_fn_inputs_and_outputs<'tcx>(
13281345 let mut ret_types = Vec :: new ( ) ;
13291346 simplify_fn_type ( self_, generics, & decl. output , tcx, 0 , & mut ret_types, & mut rgen, true , cache) ;
13301347
1331- let mut simplified_params = rgen. into_values ( ) . collect :: < Vec < _ > > ( ) ;
1332- simplified_params. sort_by_key ( |( idx, _) | -idx) ;
1333- ( arg_types, ret_types, simplified_params. into_iter ( ) . map ( |( _idx, traits) | traits) . collect ( ) )
1348+ let mut simplified_params = rgen. into_iter ( ) . collect :: < Vec < _ > > ( ) ;
1349+ simplified_params. sort_by_key ( |( _, ( idx, _) ) | -idx) ;
1350+ (
1351+ arg_types,
1352+ ret_types,
1353+ simplified_params
1354+ . iter ( )
1355+ . map ( |( name, ( _idx, _traits) ) | match name {
1356+ SimplifiedParam :: Symbol ( name) => * name,
1357+ SimplifiedParam :: Anonymous ( _) => kw:: Empty ,
1358+ SimplifiedParam :: AssociatedType ( def_id, name) => {
1359+ Symbol :: intern ( & format ! ( "{}::{}" , tcx. item_name( * def_id) , name) )
1360+ }
1361+ } )
1362+ . collect ( ) ,
1363+ simplified_params. into_iter ( ) . map ( |( _name, ( _idx, traits) ) | traits) . collect ( ) ,
1364+ )
13341365}
0 commit comments