@@ -127,9 +127,9 @@ impl<'hir> Entry<'hir> {
127
127
}
128
128
}
129
129
130
- fn is_body_owner ( self , node_id : NodeId ) -> bool {
130
+ fn is_body_owner ( self , hir_id : HirId ) -> bool {
131
131
match self . associated_body ( ) {
132
- Some ( b) => b. node_id == node_id ,
132
+ Some ( b) => b. hir_id == hir_id ,
133
133
None => false ,
134
134
}
135
135
}
@@ -438,7 +438,7 @@ impl<'hir> Map<'hir> {
438
438
}
439
439
440
440
pub fn body ( & self , id : BodyId ) -> & ' hir Body {
441
- self . read ( id. node_id ) ;
441
+ self . read_by_hir_id ( id. hir_id ) ;
442
442
443
443
// N.B., intentionally bypass `self.forest.krate()` so that we
444
444
// do not trigger a read of the whole krate here
@@ -462,9 +462,10 @@ impl<'hir> Map<'hir> {
462
462
/// Returns the `NodeId` that corresponds to the definition of
463
463
/// which this is the body of, i.e., a `fn`, `const` or `static`
464
464
/// item (possibly associated), a closure, or a `hir::AnonConst`.
465
- pub fn body_owner ( & self , BodyId { node_id } : BodyId ) -> NodeId {
465
+ pub fn body_owner ( & self , BodyId { hir_id } : BodyId ) -> NodeId {
466
+ let node_id = self . hir_to_node_id ( hir_id) ;
466
467
let parent = self . get_parent_node ( node_id) ;
467
- assert ! ( self . map[ parent. as_usize( ) ] . map_or( false , |e| e. is_body_owner( node_id ) ) ) ;
468
+ assert ! ( self . map[ parent. as_usize( ) ] . map_or( false , |e| e. is_body_owner( hir_id ) ) ) ;
468
469
parent
469
470
}
470
471
@@ -488,6 +489,12 @@ impl<'hir> Map<'hir> {
488
489
}
489
490
}
490
491
492
+ // FIXME(@ljedrz): replace the NodeId variant
493
+ pub fn maybe_body_owned_by_by_hir_id ( & self , id : HirId ) -> Option < BodyId > {
494
+ let node_id = self . hir_to_node_id ( id) ;
495
+ self . maybe_body_owned_by ( node_id)
496
+ }
497
+
491
498
/// Given a body owner's id, returns the `BodyId` associated with it.
492
499
pub fn body_owned_by ( & self , id : NodeId ) -> BodyId {
493
500
self . maybe_body_owned_by ( id) . unwrap_or_else ( || {
@@ -521,6 +528,12 @@ impl<'hir> Map<'hir> {
521
528
}
522
529
}
523
530
531
+ // FIXME(@ljedrz): replace the NodeId variant
532
+ pub fn body_owner_kind_by_hir_id ( & self , id : HirId ) -> BodyOwnerKind {
533
+ let node_id = self . hir_to_node_id ( id) ;
534
+ self . body_owner_kind ( node_id)
535
+ }
536
+
524
537
pub fn ty_param_owner ( & self , id : NodeId ) -> NodeId {
525
538
match self . get ( id) {
526
539
Node :: Item ( & Item { node : ItemKind :: Trait ( ..) , .. } ) => id,
@@ -837,6 +850,12 @@ impl<'hir> Map<'hir> {
837
850
self . local_def_id ( self . get_module_parent_node ( id) )
838
851
}
839
852
853
+ // FIXME(@ljedrz): replace the NodeId variant
854
+ pub fn get_module_parent_by_hir_id ( & self , id : HirId ) -> DefId {
855
+ let node_id = self . hir_to_node_id ( id) ;
856
+ self . get_module_parent ( node_id)
857
+ }
858
+
840
859
/// Returns the `NodeId` of `id`'s nearest module parent, or `id` itself if no
841
860
/// module parent is in this map.
842
861
pub fn get_module_parent_node ( & self , id : NodeId ) -> NodeId {
0 commit comments