@@ -185,24 +185,19 @@ crate fn get_function_type_for_search<'tcx>(
185
185
item : & clean:: Item ,
186
186
tcx : TyCtxt < ' tcx > ,
187
187
) -> Option < IndexItemFunctionType > {
188
- let ( mut inputs, mut output) = match * item. kind {
188
+ let ( inputs, output) = match * item. kind {
189
189
clean:: FunctionItem ( ref f) => get_fn_inputs_and_outputs ( f, tcx) ,
190
190
clean:: MethodItem ( ref m, _) => get_fn_inputs_and_outputs ( m, tcx) ,
191
191
clean:: TyMethodItem ( ref m) => get_fn_inputs_and_outputs ( m, tcx) ,
192
192
_ => return None ,
193
193
} ;
194
194
195
- inputs. retain ( |a| a. ty . name . is_some ( ) ) ;
196
- output. retain ( |a| a. ty . name . is_some ( ) ) ;
197
-
198
195
Some ( IndexItemFunctionType { inputs, output } )
199
196
}
200
197
201
- fn get_index_type ( clean_type : & clean:: Type , generics : Vec < TypeWithKind > ) -> RenderType {
202
- RenderType {
203
- name : get_index_type_name ( clean_type) . map ( |s| s. as_str ( ) . to_ascii_lowercase ( ) ) ,
204
- generics : if generics. is_empty ( ) { None } else { Some ( generics) } ,
205
- }
198
+ fn get_index_type ( clean_type : & clean:: Type , generics : Vec < TypeWithKind > ) -> Option < RenderType > {
199
+ get_index_type_name ( clean_type)
200
+ . map ( |s| RenderType { name : s. as_str ( ) . to_ascii_lowercase ( ) , generics } )
206
201
}
207
202
208
203
fn get_index_type_name ( clean_type : & clean:: Type ) -> Option < Symbol > {
@@ -306,19 +301,17 @@ fn add_generics_and_bounds_as_types<'tcx>(
306
301
return ;
307
302
}
308
303
}
309
- let mut index_ty = get_index_type ( & ty, generics) ;
310
- if index_ty. name . as_ref ( ) . map ( |s| s. is_empty ( ) ) . unwrap_or ( true ) {
311
- return ;
312
- }
304
+ let Some ( mut index_ty) = get_index_type ( & ty, generics)
305
+ else { return } ;
313
306
if is_full_generic {
314
307
// We remove the name of the full generic because we have no use for it.
315
- index_ty. name = Some ( String :: new ( ) ) ;
316
- res. push ( TypeWithKind :: from ( ( index_ty, ItemType :: Generic ) ) ) ;
308
+ index_ty. name = String :: new ( ) ;
309
+ res. push ( TypeWithKind { ty : index_ty, kind : ItemType :: Generic } ) ;
317
310
} else if let Some ( kind) = ty. def_id_no_primitives ( ) . map ( |did| tcx. def_kind ( did) . into ( ) ) {
318
- res. push ( TypeWithKind :: from ( ( index_ty, kind) ) ) ;
311
+ res. push ( TypeWithKind { ty : index_ty, kind } ) ;
319
312
} else if ty. is_primitive ( ) {
320
313
// This is a primitive, let's store it as such.
321
- res. push ( TypeWithKind :: from ( ( index_ty, ItemType :: Primitive ) ) ) ;
314
+ res. push ( TypeWithKind { ty : index_ty, kind : ItemType :: Primitive } ) ;
322
315
}
323
316
}
324
317
@@ -416,7 +409,9 @@ fn get_fn_inputs_and_outputs<'tcx>(
416
409
} else {
417
410
if let Some ( kind) = arg. type_ . def_id_no_primitives ( ) . map ( |did| tcx. def_kind ( did) . into ( ) )
418
411
{
419
- all_types. push ( TypeWithKind :: from ( ( get_index_type ( & arg. type_ , vec ! [ ] ) , kind) ) ) ;
412
+ if let Some ( ty) = get_index_type ( & arg. type_ , vec ! [ ] ) {
413
+ all_types. push ( TypeWithKind { ty, kind } ) ;
414
+ }
420
415
}
421
416
}
422
417
}
@@ -429,7 +424,9 @@ fn get_fn_inputs_and_outputs<'tcx>(
429
424
if let Some ( kind) =
430
425
return_type. def_id_no_primitives ( ) . map ( |did| tcx. def_kind ( did) . into ( ) )
431
426
{
432
- ret_types. push ( TypeWithKind :: from ( ( get_index_type ( return_type, vec ! [ ] ) , kind) ) ) ;
427
+ if let Some ( ty) = get_index_type ( return_type, vec ! [ ] ) {
428
+ ret_types. push ( TypeWithKind { ty, kind } ) ;
429
+ }
433
430
}
434
431
}
435
432
}
0 commit comments