@@ -226,17 +226,17 @@ fn get_index_type_name(clean_type: &clean::Type) -> Option<Symbol> {
226226 Some ( path. segments . last ( ) . unwrap ( ) . name )
227227 }
228228 // 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 ) ,
230230 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+ }
232234 clean:: BareFunction ( _)
233235 | clean:: Tuple ( _)
234236 | clean:: Slice ( _)
235237 | clean:: Array ( _, _)
236- | clean:: RawPointer ( _, _)
237238 | clean:: QPath { .. }
238- | clean:: Infer
239- | clean:: ImplTrait ( _) => None ,
239+ | clean:: Infer => None ,
240240 }
241241}
242242
@@ -264,10 +264,12 @@ fn add_generics_and_bounds_as_types<'tcx, 'a>(
264264 mut generics : Vec < TypeWithKind > ,
265265 cache : & Cache ,
266266 ) {
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 ( ) ;
268270 let generics_empty = generics. is_empty ( ) ;
269271
270- if is_full_generic {
272+ if anonymous {
271273 if generics_empty {
272274 // This is a type parameter with no trait bounds (for example: `T` in
273275 // `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>(
318320 if index_ty. name . as_ref ( ) . map ( |s| s. is_empty ( ) && generics_empty) . unwrap_or ( true ) {
319321 return ;
320322 }
321- if is_full_generic {
323+ if anonymous {
322324 // We remove the name of the full generic because we have no use for it.
323325 index_ty. name = Some ( String :: new ( ) ) ;
324326 res. push ( TypeWithKind :: from ( ( index_ty, ItemType :: Generic ) ) ) ;
@@ -398,6 +400,23 @@ fn add_generics_and_bounds_as_types<'tcx, 'a>(
398400 }
399401 insert_ty ( res, tcx, arg. clone ( ) , ty_generics, cache) ;
400402 }
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) ;
401420 } else {
402421 // This is not a type parameter. So for example if we have `T, U: Option<T>`, and we're
403422 // looking at `Option`, we enter this "else" condition, otherwise if it's `T`, we don't.
0 commit comments