@@ -3,7 +3,7 @@ use std::collections::BTreeMap;
33
44use rustc_data_structures:: fx:: FxHashMap ;
55use rustc_middle:: ty:: TyCtxt ;
6- use rustc_span:: symbol:: Symbol ;
6+ use rustc_span:: symbol:: { kw , Symbol } ;
77use serde:: ser:: { Serialize , SerializeStruct , Serializer } ;
88
99use crate :: clean;
@@ -220,7 +220,8 @@ fn get_index_type_name(clean_type: &clean::Type) -> Option<Symbol> {
220220 let path = & bounds[ 0 ] . trait_ ;
221221 Some ( path. segments . last ( ) . unwrap ( ) . name )
222222 }
223- clean:: Generic ( s) => Some ( s) ,
223+ // We return an empty name because we don't care about the generic name itself.
224+ clean:: Generic ( _) => Some ( kw:: Empty ) ,
224225 clean:: Primitive ( ref p) => Some ( p. as_sym ( ) ) ,
225226 clean:: BorrowedRef { ref type_, .. } => get_index_type_name ( type_) ,
226227 clean:: BareFunction ( _)
@@ -258,9 +259,10 @@ fn add_generics_and_bounds_as_types<'tcx>(
258259 cache : & Cache ,
259260 ) {
260261 let is_full_generic = ty. is_full_generic ( ) ;
262+ let generics_empty = generics. is_empty ( ) ;
261263
262264 if is_full_generic {
263- if generics . is_empty ( ) {
265+ if generics_empty {
264266 // This is a type parameter with no trait bounds (for example: `T` in
265267 // `fn f<T>(p: T)`, so not useful for the rustdoc search because we would end up
266268 // with an empty type with an empty name. Let's just discard it.
@@ -307,7 +309,7 @@ fn add_generics_and_bounds_as_types<'tcx>(
307309 }
308310 }
309311 let mut index_ty = get_index_type ( & ty, generics) ;
310- if index_ty. name . as_ref ( ) . map ( |s| s. is_empty ( ) ) . unwrap_or ( true ) {
312+ if index_ty. name . as_ref ( ) . map ( |s| s. is_empty ( ) && generics_empty ) . unwrap_or ( true ) {
311313 return ;
312314 }
313315 if is_full_generic {
0 commit comments