@@ -396,10 +396,10 @@ impl<'hir> Map<'hir> {
396396 }
397397 }
398398
399- pub fn enclosing_body_owner ( self , hir_id : HirId ) -> HirId {
399+ pub fn enclosing_body_owner ( self , hir_id : HirId ) -> LocalDefId {
400400 for ( parent, _) in self . parent_iter ( hir_id) {
401- if let Some ( body) = self . maybe_body_owned_by ( parent) {
402- return self . body_owner ( body) ;
401+ if let Some ( body) = self . find ( parent) . map ( associated_body ) . flatten ( ) {
402+ return self . body_owner_def_id ( body) ;
403403 }
404404 }
405405
@@ -419,19 +419,20 @@ impl<'hir> Map<'hir> {
419419 self . local_def_id ( self . body_owner ( id) )
420420 }
421421
422- /// Given a `HirId `, returns the `BodyId` associated with it,
422+ /// Given a `LocalDefId `, returns the `BodyId` associated with it,
423423 /// if the node is a body owner, otherwise returns `None`.
424- pub fn maybe_body_owned_by ( self , hir_id : HirId ) -> Option < BodyId > {
425- self . find ( hir_id ) . map ( associated_body) . flatten ( )
424+ pub fn maybe_body_owned_by ( self , id : LocalDefId ) -> Option < BodyId > {
425+ self . get_if_local ( id . to_def_id ( ) ) . map ( associated_body) . flatten ( )
426426 }
427427
428428 /// Given a body owner's id, returns the `BodyId` associated with it.
429- pub fn body_owned_by ( self , id : HirId ) -> BodyId {
429+ pub fn body_owned_by ( self , id : LocalDefId ) -> BodyId {
430430 self . maybe_body_owned_by ( id) . unwrap_or_else ( || {
431+ let hir_id = self . local_def_id_to_hir_id ( id) ;
431432 span_bug ! (
432- self . span( id ) ,
433+ self . span( hir_id ) ,
433434 "body_owned_by: {} has no associated body" ,
434- self . node_to_string( id )
435+ self . node_to_string( hir_id )
435436 ) ;
436437 } )
437438 }
@@ -670,7 +671,7 @@ impl<'hir> Map<'hir> {
670671 /// Whether the expression pointed at by `hir_id` belongs to a `const` evaluation context.
671672 /// Used exclusively for diagnostics, to avoid suggestion function calls.
672673 pub fn is_inside_const_context ( self , hir_id : HirId ) -> bool {
673- self . body_const_context ( self . local_def_id ( self . enclosing_body_owner ( hir_id) ) ) . is_some ( )
674+ self . body_const_context ( self . enclosing_body_owner ( hir_id) ) . is_some ( )
674675 }
675676
676677 /// Retrieves the `HirId` for `id`'s enclosing method, unless there's a
0 commit comments