@@ -226,7 +226,7 @@ fn get_index_type_name(clean_type: &clean::Type) -> Option<Symbol> {
226
226
Some ( path. segments . last ( ) . unwrap ( ) . name )
227
227
}
228
228
// We return an empty name because we don't care about the generic name itself.
229
- clean:: Generic ( _) => Some ( kw:: Empty ) ,
229
+ clean:: Generic ( _) | clean :: ImplTrait ( _ ) => Some ( kw:: Empty ) ,
230
230
clean:: Primitive ( ref p) => Some ( p. as_sym ( ) ) ,
231
231
clean:: BorrowedRef { ref type_, .. } => get_index_type_name ( type_) ,
232
232
clean:: BareFunction ( _)
@@ -235,8 +235,7 @@ fn get_index_type_name(clean_type: &clean::Type) -> Option<Symbol> {
235
235
| clean:: Array ( _, _)
236
236
| clean:: RawPointer ( _, _)
237
237
| clean:: QPath { .. }
238
- | clean:: Infer
239
- | clean:: ImplTrait ( _) => None ,
238
+ | clean:: Infer => None ,
240
239
}
241
240
}
242
241
@@ -264,10 +263,12 @@ fn add_generics_and_bounds_as_types<'tcx, 'a>(
264
263
mut generics : Vec < TypeWithKind > ,
265
264
cache : & Cache ,
266
265
) {
267
- let is_full_generic = ty. is_full_generic ( ) ;
266
+ // generics and impl trait are both identified by their generics,
267
+ // rather than a type name itself
268
+ let anonymous = ty. is_full_generic ( ) || ty. is_impl_trait ( ) ;
268
269
let generics_empty = generics. is_empty ( ) ;
269
270
270
- if is_full_generic {
271
+ if anonymous {
271
272
if generics_empty {
272
273
// This is a type parameter with no trait bounds (for example: `T` in
273
274
// `fn f<T>(p: T)`, so not useful for the rustdoc search because we would end up
@@ -318,7 +319,7 @@ fn add_generics_and_bounds_as_types<'tcx, 'a>(
318
319
if index_ty. name . as_ref ( ) . map ( |s| s. is_empty ( ) && generics_empty) . unwrap_or ( true ) {
319
320
return ;
320
321
}
321
- if is_full_generic {
322
+ if anonymous {
322
323
// We remove the name of the full generic because we have no use for it.
323
324
index_ty. name = Some ( String :: new ( ) ) ;
324
325
res. push ( TypeWithKind :: from ( ( index_ty, ItemType :: Generic ) ) ) ;
@@ -398,6 +399,23 @@ fn add_generics_and_bounds_as_types<'tcx, 'a>(
398
399
}
399
400
insert_ty ( res, tcx, arg. clone ( ) , ty_generics, cache) ;
400
401
}
402
+ } else if let Type :: ImplTrait ( ref bounds) = * arg {
403
+ let mut ty_generics = Vec :: new ( ) ;
404
+ for bound in bounds {
405
+ if let Some ( path) = bound. get_trait_path ( ) {
406
+ let ty = Type :: Path { path } ;
407
+ add_generics_and_bounds_as_types (
408
+ self_,
409
+ generics,
410
+ & ty,
411
+ tcx,
412
+ recurse + 1 ,
413
+ & mut ty_generics,
414
+ cache,
415
+ ) ;
416
+ }
417
+ }
418
+ insert_ty ( res, tcx, arg. clone ( ) , ty_generics, cache) ;
401
419
} else {
402
420
// This is not a type parameter. So for example if we have `T, U: Option<T>`, and we're
403
421
// looking at `Option`, we enter this "else" condition, otherwise if it's `T`, we don't.
0 commit comments