@@ -646,9 +646,25 @@ pub(crate) fn build_index<'tcx>(
646
646
full_paths. push ( ( * index, path) ) ;
647
647
}
648
648
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
+
649
665
let has_aliases = !self . aliases . is_empty ( ) ;
650
666
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 } ) ?;
652
668
crate_data. serialize_field ( "t" , & types) ?;
653
669
crate_data. serialize_field ( "n" , & names) ?;
654
670
crate_data. serialize_field ( "q" , & full_paths) ?;
@@ -660,6 +676,7 @@ pub(crate) fn build_index<'tcx>(
660
676
crate_data. serialize_field ( "b" , & self . associated_item_disambiguators ) ?;
661
677
crate_data. serialize_field ( "c" , & bitmap_to_string ( & deprecated) ) ?;
662
678
crate_data. serialize_field ( "e" , & bitmap_to_string ( & self . empty_desc ) ) ?;
679
+ crate_data. serialize_field ( "P" , & param_names) ?;
663
680
if has_aliases {
664
681
crate_data. serialize_field ( "a" , & self . aliases ) ?;
665
682
}
@@ -758,7 +775,7 @@ pub(crate) fn get_function_type_for_search<'tcx>(
758
775
None
759
776
}
760
777
} ) ;
761
- let ( mut inputs, mut output, where_clause) = match item. kind {
778
+ let ( mut inputs, mut output, param_names , where_clause) = match item. kind {
762
779
clean:: ForeignFunctionItem ( ref f, _)
763
780
| clean:: FunctionItem ( ref f)
764
781
| clean:: MethodItem ( ref f, _)
@@ -771,7 +788,7 @@ pub(crate) fn get_function_type_for_search<'tcx>(
771
788
inputs. retain ( |a| a. id . is_some ( ) || a. generics . is_some ( ) ) ;
772
789
output. retain ( |a| a. id . is_some ( ) || a. generics . is_some ( ) ) ;
773
790
774
- Some ( IndexItemFunctionType { inputs, output, where_clause } )
791
+ Some ( IndexItemFunctionType { inputs, output, where_clause, param_names } )
775
792
}
776
793
777
794
fn get_index_type (
@@ -1285,7 +1302,7 @@ fn get_fn_inputs_and_outputs<'tcx>(
1285
1302
tcx : TyCtxt < ' tcx > ,
1286
1303
impl_or_trait_generics : Option < & ( clean:: Type , clean:: Generics ) > ,
1287
1304
cache : & Cache ,
1288
- ) -> ( Vec < RenderType > , Vec < RenderType > , Vec < Vec < RenderType > > ) {
1305
+ ) -> ( Vec < RenderType > , Vec < RenderType > , Vec < Symbol > , Vec < Vec < RenderType > > ) {
1289
1306
let decl = & func. decl ;
1290
1307
1291
1308
let mut rgen: FxIndexMap < SimplifiedParam , ( isize , Vec < RenderType > ) > = Default :: default ( ) ;
@@ -1331,7 +1348,21 @@ fn get_fn_inputs_and_outputs<'tcx>(
1331
1348
let mut ret_types = Vec :: new ( ) ;
1332
1349
simplify_fn_type ( self_, generics, & decl. output , tcx, 0 , & mut ret_types, & mut rgen, true , cache) ;
1333
1350
1334
- let mut simplified_params = rgen. into_values ( ) . collect :: < Vec < _ > > ( ) ;
1335
- simplified_params. sort_by_key ( |( idx, _) | -idx) ;
1336
- ( arg_types, ret_types, simplified_params. into_iter ( ) . map ( |( _idx, traits) | traits) . collect ( ) )
1351
+ let mut simplified_params = rgen. into_iter ( ) . collect :: < Vec < _ > > ( ) ;
1352
+ simplified_params. sort_by_key ( |( _, ( idx, _) ) | -idx) ;
1353
+ (
1354
+ arg_types,
1355
+ ret_types,
1356
+ simplified_params
1357
+ . iter ( )
1358
+ . map ( |( name, ( _idx, _traits) ) | match name {
1359
+ SimplifiedParam :: Symbol ( name) => * name,
1360
+ SimplifiedParam :: Anonymous ( _) => kw:: Empty ,
1361
+ SimplifiedParam :: AssociatedType ( def_id, name) => {
1362
+ Symbol :: intern ( & format ! ( "{}::{}" , tcx. item_name( * def_id) , name) )
1363
+ }
1364
+ } )
1365
+ . collect ( ) ,
1366
+ simplified_params. into_iter ( ) . map ( |( _name, ( _idx, traits) ) | traits) . collect ( ) ,
1367
+ )
1337
1368
}
0 commit comments