@@ -3,7 +3,7 @@ use std::collections::BTreeMap;
3
3
4
4
use rustc_data_structures:: fx:: FxHashMap ;
5
5
use rustc_middle:: ty:: TyCtxt ;
6
- use rustc_span:: symbol:: Symbol ;
6
+ use rustc_span:: symbol:: { kw , Symbol } ;
7
7
use serde:: ser:: { Serialize , SerializeStruct , Serializer } ;
8
8
9
9
use crate :: clean;
@@ -220,7 +220,8 @@ fn get_index_type_name(clean_type: &clean::Type) -> Option<Symbol> {
220
220
let path = & bounds[ 0 ] . trait_ ;
221
221
Some ( path. segments . last ( ) . unwrap ( ) . name )
222
222
}
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 ) ,
224
225
clean:: Primitive ( ref p) => Some ( p. as_sym ( ) ) ,
225
226
clean:: BorrowedRef { ref type_, .. } => get_index_type_name ( type_) ,
226
227
clean:: BareFunction ( _)
@@ -258,9 +259,10 @@ fn add_generics_and_bounds_as_types<'tcx>(
258
259
cache : & Cache ,
259
260
) {
260
261
let is_full_generic = ty. is_full_generic ( ) ;
262
+ let generics_empty = generics. is_empty ( ) ;
261
263
262
264
if is_full_generic {
263
- if generics . is_empty ( ) {
265
+ if generics_empty {
264
266
// This is a type parameter with no trait bounds (for example: `T` in
265
267
// `fn f<T>(p: T)`, so not useful for the rustdoc search because we would end up
266
268
// 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>(
307
309
}
308
310
}
309
311
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 ) {
311
313
return ;
312
314
}
313
315
if is_full_generic {
0 commit comments