@@ -310,16 +310,16 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> {
310
310
// `public_items` map, so we can skip inserting into the
311
311
// paths map if there was already an entry present and we're
312
312
// not a public item.
313
- if !self . cache . paths . contains_key ( & item. item_id . expect_def_id ( ) )
313
+ let item_def_id = item. item_id . expect_def_id ( ) ;
314
+ if !self . cache . paths . contains_key ( & item_def_id)
314
315
|| self
315
316
. cache
316
317
. effective_visibilities
317
- . is_directly_public ( self . tcx , item . item_id . expect_def_id ( ) )
318
+ . is_directly_public ( self . tcx , item_def_id )
318
319
{
319
- self . cache . paths . insert (
320
- item. item_id . expect_def_id ( ) ,
321
- ( self . cache . stack . clone ( ) , item. type_ ( ) ) ,
322
- ) ;
320
+ self . cache
321
+ . paths
322
+ . insert ( item_def_id, ( self . cache . stack . clone ( ) , item. type_ ( ) ) ) ;
323
323
}
324
324
}
325
325
}
@@ -381,9 +381,7 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> {
381
381
&& adt. is_fundamental ( )
382
382
{
383
383
for ty in generics {
384
- if let Some ( did) = ty. def_id ( self . cache ) {
385
- dids. insert ( did) ;
386
- }
384
+ dids. extend ( ty. def_id ( self . cache ) ) ;
387
385
}
388
386
}
389
387
}
@@ -396,32 +394,26 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> {
396
394
. primitive_type ( )
397
395
. and_then ( |t| self . cache . primitive_locations . get ( & t) . cloned ( ) ) ;
398
396
399
- if let Some ( did) = did {
400
- dids. insert ( did) ;
401
- }
397
+ dids. extend ( did) ;
402
398
}
403
399
}
404
400
405
401
if let Some ( generics) = i. trait_ . as_ref ( ) . and_then ( |t| t. generics ( ) ) {
406
402
for bound in generics {
407
- if let Some ( did) = bound. def_id ( self . cache ) {
408
- dids. insert ( did) ;
409
- }
403
+ dids. extend ( bound. def_id ( self . cache ) ) ;
410
404
}
411
405
}
412
406
let impl_item = Impl { impl_item : item } ;
413
- if impl_item. trait_did ( ) . map_or ( true , |d| self . cache . traits . contains_key ( & d) ) {
407
+ let impl_did = impl_item. def_id ( ) ;
408
+ let trait_did = impl_item. trait_did ( ) ;
409
+ if trait_did. map_or ( true , |d| self . cache . traits . contains_key ( & d) ) {
414
410
for did in dids {
415
- if self . impl_ids . entry ( did) . or_default ( ) . insert ( impl_item. def_id ( ) ) {
416
- self . cache
417
- . impls
418
- . entry ( did)
419
- . or_insert_with ( Vec :: new)
420
- . push ( impl_item. clone ( ) ) ;
411
+ if self . impl_ids . entry ( did) . or_default ( ) . insert ( impl_did) {
412
+ self . cache . impls . entry ( did) . or_default ( ) . push ( impl_item. clone ( ) ) ;
421
413
}
422
414
}
423
415
} else {
424
- let trait_did = impl_item . trait_did ( ) . expect ( "no trait did" ) ;
416
+ let trait_did = trait_did. expect ( "no trait did" ) ;
425
417
self . cache . orphan_trait_impls . push ( ( trait_did, dids, impl_item) ) ;
426
418
}
427
419
None
0 commit comments