@@ -171,11 +171,20 @@ crate fn get_real_types(
171
171
cx : & DocContext < ' _ > ,
172
172
recurse : i32 ,
173
173
) -> FxHashSet < ( Type , TypeKind ) > {
174
+ fn insert ( res : & mut FxHashSet < ( Type , TypeKind ) > , cx : & DocContext < ' _ > , ty : Type ) {
175
+ if let Some ( kind) = ty. def_id ( ) . map ( |did| cx. tcx . def_kind ( did) . clean ( cx) ) {
176
+ res. insert ( ( ty, kind) ) ;
177
+ } else if ty. is_primitive ( ) {
178
+ // This is a primitive, let's store it as such.
179
+ res. insert ( ( ty, TypeKind :: Primitive ) ) ;
180
+ }
181
+ }
174
182
let mut res = FxHashSet :: default ( ) ;
175
183
if recurse >= 10 {
176
184
// FIXME: remove this whole recurse thing when the recursion bug is fixed
177
185
return res;
178
186
}
187
+
179
188
if arg. is_full_generic ( ) {
180
189
let arg_s = Symbol :: intern ( & arg. print ( & cx. cache ) . to_string ( ) ) ;
181
190
if let Some ( where_pred) = generics. where_predicates . iter ( ) . find ( |g| match g {
@@ -194,11 +203,7 @@ crate fn get_real_types(
194
203
if !adds. is_empty ( ) {
195
204
res. extend ( adds) ;
196
205
} else if !ty. is_full_generic ( ) {
197
- if let Some ( kind) =
198
- ty. def_id ( ) . map ( |did| cx. tcx . def_kind ( did) . clean ( cx) )
199
- {
200
- res. insert ( ( ty, kind) ) ;
201
- }
206
+ insert ( & mut res, cx, ty) ;
202
207
}
203
208
}
204
209
}
@@ -212,26 +217,22 @@ crate fn get_real_types(
212
217
if !adds. is_empty ( ) {
213
218
res. extend ( adds) ;
214
219
} else if !ty. is_full_generic ( ) {
215
- if let Some ( kind) = ty. def_id ( ) . map ( |did| cx. tcx . def_kind ( did) . clean ( cx) ) {
216
- res. insert ( ( ty. clone ( ) , kind) ) ;
217
- }
220
+ insert ( & mut res, cx, ty) ;
218
221
}
219
222
}
220
223
}
221
224
}
222
225
} else {
223
- if let Some ( kind) = arg. def_id ( ) . map ( |did| cx. tcx . def_kind ( did) . clean ( cx) ) {
224
- res. insert ( ( arg. clone ( ) , kind) ) ;
225
- }
226
+ insert ( & mut res, cx, arg. clone ( ) ) ;
226
227
if let Some ( gens) = arg. generics ( ) {
227
228
for gen in gens. iter ( ) {
228
229
if gen. is_full_generic ( ) {
229
230
let adds = get_real_types ( generics, gen, cx, recurse + 1 ) ;
230
231
if !adds. is_empty ( ) {
231
232
res. extend ( adds) ;
232
233
}
233
- } else if let Some ( kind ) = gen . def_id ( ) . map ( |did| cx . tcx . def_kind ( did ) . clean ( cx ) ) {
234
- res . insert ( ( gen. clone ( ) , kind ) ) ;
234
+ } else {
235
+ insert ( & mut res , cx , gen. clone ( ) ) ;
235
236
}
236
237
}
237
238
}
0 commit comments