@@ -615,23 +615,16 @@ impl<'hir> Map<'hir> {
615
615
result
616
616
}
617
617
618
- /// Similar to `get_parent`; returns the parent node-ID , or just `hir_id` if there
619
- /// is no parent. Note that the parent may be `CRATE_NODE_ID `, which is not itself
618
+ /// Similar to `get_parent`; returns the parent HIR Id , or just `hir_id` if there
619
+ /// is no parent. Note that the parent may be `CRATE_HIR_ID `, which is not itself
620
620
/// present in the map, so passing the return value of `get_parent_node` to
621
621
/// `get` may in fact panic.
622
- /// This function returns the immediate parent in the AST , whereas `get_parent`
622
+ /// This function returns the immediate parent in the HIR , whereas `get_parent`
623
623
/// returns the enclosing item. Note that this might not be the actual parent
624
- /// node in the AST -- some kinds of nodes are not in the map and these will
624
+ /// node in the HIR -- some kinds of nodes are not in the map and these will
625
625
/// never appear as the parent node. Thus, you can always walk the parent nodes
626
- /// from a node to the root of the AST (unless you get back the same ID here,
626
+ /// from a node to the root of the HIR (unless you get back the same ID here,
627
627
/// which can happen if the ID is not in the map itself or is just weird).
628
- pub fn get_parent_node ( & self , id : NodeId ) -> NodeId {
629
- let hir_id = self . node_to_hir_id ( id) ;
630
- let parent_hir_id = self . get_parent_node_by_hir_id ( hir_id) ;
631
- self . hir_to_node_id ( parent_hir_id)
632
- }
633
-
634
- // FIXME(@ljedrz): replace the `NodeId` variant.
635
628
pub fn get_parent_node_by_hir_id ( & self , hir_id : HirId ) -> HirId {
636
629
if self . dep_graph . is_fully_enabled ( ) {
637
630
let hir_id_owner = hir_id. owner ;
@@ -646,12 +639,12 @@ impl<'hir> Map<'hir> {
646
639
647
640
/// Check if the node is an argument. An argument is a local variable whose
648
641
/// immediate parent is an item or a closure.
649
- pub fn is_argument ( & self , id : NodeId ) -> bool {
650
- match self . find ( id) {
642
+ pub fn is_argument ( & self , id : HirId ) -> bool {
643
+ match self . find_by_hir_id ( id) {
651
644
Some ( Node :: Binding ( _) ) => ( ) ,
652
645
_ => return false ,
653
646
}
654
- match self . find ( self . get_parent_node ( id) ) {
647
+ match self . find_by_hir_id ( self . get_parent_node_by_hir_id ( id) ) {
655
648
Some ( Node :: Item ( _) ) |
656
649
Some ( Node :: TraitItem ( _) ) |
657
650
Some ( Node :: ImplItem ( _) ) => true ,
0 commit comments