@@ -310,16 +310,16 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> {
310310 // `public_items` map, so we can skip inserting into the
311311 // paths map if there was already an entry present and we're
312312 // 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)
314315 || self
315316 . cache
316317 . effective_visibilities
317- . is_directly_public ( self . tcx , item . item_id . expect_def_id ( ) )
318+ . is_directly_public ( self . tcx , item_def_id )
318319 {
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_ ( ) ) ) ;
323323 }
324324 }
325325 }
@@ -381,9 +381,7 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> {
381381 && adt. is_fundamental ( )
382382 {
383383 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 ) ) ;
387385 }
388386 }
389387 }
@@ -396,32 +394,26 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> {
396394 . primitive_type ( )
397395 . and_then ( |t| self . cache . primitive_locations . get ( & t) . cloned ( ) ) ;
398396
399- if let Some ( did) = did {
400- dids. insert ( did) ;
401- }
397+ dids. extend ( did) ;
402398 }
403399 }
404400
405401 if let Some ( generics) = i. trait_ . as_ref ( ) . and_then ( |t| t. generics ( ) ) {
406402 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 ) ) ;
410404 }
411405 }
412406 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) ) {
414410 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 ( ) ) ;
421413 }
422414 }
423415 } else {
424- let trait_did = impl_item . trait_did ( ) . expect ( "no trait did" ) ;
416+ let trait_did = trait_did. expect ( "no trait did" ) ;
425417 self . cache . orphan_trait_impls . push ( ( trait_did, dids, impl_item) ) ;
426418 }
427419 None
0 commit comments