@@ -615,23 +615,16 @@ impl<'hir> Map<'hir> {
615615 result
616616 }
617617
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
620620 /// present in the map, so passing the return value of `get_parent_node` to
621621 /// `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`
623623 /// 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
625625 /// 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,
627627 /// 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.
635628 pub fn get_parent_node_by_hir_id ( & self , hir_id : HirId ) -> HirId {
636629 if self . dep_graph . is_fully_enabled ( ) {
637630 let hir_id_owner = hir_id. owner ;
@@ -646,12 +639,12 @@ impl<'hir> Map<'hir> {
646639
647640 /// Check if the node is an argument. An argument is a local variable whose
648641 /// 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) {
651644 Some ( Node :: Binding ( _) ) => ( ) ,
652645 _ => return false ,
653646 }
654- match self . find ( self . get_parent_node ( id) ) {
647+ match self . find_by_hir_id ( self . get_parent_node_by_hir_id ( id) ) {
655648 Some ( Node :: Item ( _) ) |
656649 Some ( Node :: TraitItem ( _) ) |
657650 Some ( Node :: ImplItem ( _) ) => true ,
0 commit comments