@@ -381,7 +381,7 @@ impl<'hir> Map<'hir> {
381381 }
382382
383383 pub fn body ( & self , id : BodyId ) -> & ' hir Body < ' hir > {
384- self . tcx . hir_owner_nodes ( id. hir_id . owner ) . unwrap ( ) . bodies . get ( & id. hir_id . local_id ) . unwrap ( )
384+ self . tcx . hir_owner_nodes ( id. hir_id . owner ) . unwrap ( ) . bodies [ id. hir_id . local_id ] . unwrap ( )
385385 }
386386
387387 pub fn fn_decl_by_hir_id ( & self , hir_id : HirId ) -> Option < & ' hir FnDecl < ' hir > > {
@@ -500,10 +500,13 @@ impl<'hir> Map<'hir> {
500500 . iter_enumerated ( )
501501 . flat_map ( move |( owner, owner_info) | {
502502 let bodies = & owner_info. as_ref ( ) ?. bodies ;
503- Some ( bodies. keys ( ) . map ( move |& local_id| {
503+ Some ( bodies. iter_enumerated ( ) . filter_map ( move |( local_id, body) | {
504+ if body. is_none ( ) {
505+ return None ;
506+ }
504507 let hir_id = HirId { owner, local_id } ;
505508 let body_id = BodyId { hir_id } ;
506- self . body_owner_def_id ( body_id)
509+ Some ( self . body_owner_def_id ( body_id) )
507510 } ) )
508511 } )
509512 . flatten ( )
@@ -517,10 +520,13 @@ impl<'hir> Map<'hir> {
517520 par_iter ( & self . krate ( ) . owners . raw ) . enumerate ( ) . for_each ( |( owner, owner_info) | {
518521 let owner = LocalDefId :: new ( owner) ;
519522 if let Some ( owner_info) = owner_info {
520- par_iter ( & owner_info. bodies ) . for_each ( |( & local_id, _) | {
521- let hir_id = HirId { owner, local_id } ;
522- let body_id = BodyId { hir_id } ;
523- f ( self . body_owner_def_id ( body_id) )
523+ par_iter ( & owner_info. bodies . raw ) . enumerate ( ) . for_each ( |( local_id, body) | {
524+ if body. is_some ( ) {
525+ let local_id = ItemLocalId :: new ( local_id) ;
526+ let hir_id = HirId { owner, local_id } ;
527+ let body_id = BodyId { hir_id } ;
528+ f ( self . body_owner_def_id ( body_id) )
529+ }
524530 } )
525531 }
526532 } ) ;
0 commit comments