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