@@ -171,11 +171,20 @@ crate fn get_real_types(
171171 cx : & DocContext < ' _ > ,
172172 recurse : i32 ,
173173) -> 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+ }
174182 let mut res = FxHashSet :: default ( ) ;
175183 if recurse >= 10 {
176184 // FIXME: remove this whole recurse thing when the recursion bug is fixed
177185 return res;
178186 }
187+
179188 if arg. is_full_generic ( ) {
180189 let arg_s = Symbol :: intern ( & arg. print ( & cx. cache ) . to_string ( ) ) ;
181190 if let Some ( where_pred) = generics. where_predicates . iter ( ) . find ( |g| match g {
@@ -194,11 +203,7 @@ crate fn get_real_types(
194203 if !adds. is_empty ( ) {
195204 res. extend ( adds) ;
196205 } 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) ;
202207 }
203208 }
204209 }
@@ -212,26 +217,22 @@ crate fn get_real_types(
212217 if !adds. is_empty ( ) {
213218 res. extend ( adds) ;
214219 } 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) ;
218221 }
219222 }
220223 }
221224 }
222225 } 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 ( ) ) ;
226227 if let Some ( gens) = arg. generics ( ) {
227228 for gen in gens. iter ( ) {
228229 if gen. is_full_generic ( ) {
229230 let adds = get_real_types ( generics, gen, cx, recurse + 1 ) ;
230231 if !adds. is_empty ( ) {
231232 res. extend ( adds) ;
232233 }
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 ( ) ) ;
235236 }
236237 }
237238 }
0 commit comments