@@ -442,16 +442,16 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> {
442
442
// `public_items` map, so we can skip inserting into the
443
443
// paths map if there was already an entry present and we're
444
444
// not a public item.
445
- if !self . cache . paths . contains_key ( & item. item_id . expect_def_id ( ) )
445
+ let item_def_id = item. item_id . expect_def_id ( ) ;
446
+ if !self . cache . paths . contains_key ( & item_def_id)
446
447
|| self
447
448
. cache
448
449
. effective_visibilities
449
- . is_directly_public ( self . tcx , item . item_id . expect_def_id ( ) )
450
+ . is_directly_public ( self . tcx , item_def_id )
450
451
{
451
- self . cache . paths . insert (
452
- item. item_id . expect_def_id ( ) ,
453
- ( self . cache . stack . clone ( ) , item. type_ ( ) ) ,
454
- ) ;
452
+ self . cache
453
+ . paths
454
+ . insert ( item_def_id, ( self . cache . stack . clone ( ) , item. type_ ( ) ) ) ;
455
455
}
456
456
}
457
457
}
@@ -514,9 +514,7 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> {
514
514
&& adt. is_fundamental ( )
515
515
{
516
516
for ty in generics {
517
- if let Some ( did) = ty. def_id ( self . cache ) {
518
- dids. insert ( did) ;
519
- }
517
+ dids. extend ( ty. def_id ( self . cache ) ) ;
520
518
}
521
519
}
522
520
}
@@ -529,32 +527,26 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> {
529
527
. primitive_type ( )
530
528
. and_then ( |t| self . cache . primitive_locations . get ( & t) . cloned ( ) ) ;
531
529
532
- if let Some ( did) = did {
533
- dids. insert ( did) ;
534
- }
530
+ dids. extend ( did) ;
535
531
}
536
532
}
537
533
538
534
if let Some ( generics) = i. trait_ . as_ref ( ) . and_then ( |t| t. generics ( ) ) {
539
535
for bound in generics {
540
- if let Some ( did) = bound. def_id ( self . cache ) {
541
- dids. insert ( did) ;
542
- }
536
+ dids. extend ( bound. def_id ( self . cache ) ) ;
543
537
}
544
538
}
545
539
let impl_item = Impl { impl_item : item } ;
546
- if impl_item. trait_did ( ) . map_or ( true , |d| self . cache . traits . contains_key ( & d) ) {
540
+ let impl_did = impl_item. def_id ( ) ;
541
+ let trait_did = impl_item. trait_did ( ) ;
542
+ if trait_did. map_or ( true , |d| self . cache . traits . contains_key ( & d) ) {
547
543
for did in dids {
548
- if self . impl_ids . entry ( did) . or_default ( ) . insert ( impl_item. def_id ( ) ) {
549
- self . cache
550
- . impls
551
- . entry ( did)
552
- . or_insert_with ( Vec :: new)
553
- . push ( impl_item. clone ( ) ) ;
544
+ if self . impl_ids . entry ( did) . or_default ( ) . insert ( impl_did) {
545
+ self . cache . impls . entry ( did) . or_default ( ) . push ( impl_item. clone ( ) ) ;
554
546
}
555
547
}
556
548
} else {
557
- let trait_did = impl_item . trait_did ( ) . expect ( "no trait did" ) ;
549
+ let trait_did = trait_did. expect ( "no trait did" ) ;
558
550
self . cache . orphan_trait_impls . push ( ( trait_did, dids, impl_item) ) ;
559
551
}
560
552
None
0 commit comments