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