@@ -401,6 +401,12 @@ impl<'hir> Map<'hir> {
401401 }
402402 }
403403
404+ // FIXME(@ljedrz): replace the NodeId variant
405+ pub fn describe_def_by_hir_id ( & self , hir_id : HirId ) -> Option < Def > {
406+ let node_id = self . hir_to_node_id ( hir_id) ;
407+ self . describe_def ( node_id)
408+ }
409+
404410 fn entry_count ( & self ) -> usize {
405411 self . map . len ( )
406412 }
@@ -445,6 +451,12 @@ impl<'hir> Map<'hir> {
445451 }
446452 }
447453
454+ // FIXME(@ljedrz): replace the NodeId variant
455+ pub fn fn_decl_by_hir_id ( & self , hir_id : HirId ) -> Option < FnDecl > {
456+ let node_id = self . hir_to_node_id ( hir_id) ;
457+ self . fn_decl ( node_id)
458+ }
459+
448460 /// Returns the `NodeId` that corresponds to the definition of
449461 /// which this is the body of, i.e., a `fn`, `const` or `static`
450462 /// item (possibly associated), a closure, or a `hir::AnonConst`.
@@ -855,6 +867,12 @@ impl<'hir> Map<'hir> {
855867 self . local_def_id ( self . get_parent ( id) )
856868 }
857869
870+ // FIXME(@ljedrz): replace the NodeId variant
871+ pub fn get_parent_did_by_hir_id ( & self , id : HirId ) -> DefId {
872+ let node_id = self . hir_to_node_id ( id) ;
873+ self . get_parent_did ( node_id)
874+ }
875+
858876 pub fn get_foreign_abi ( & self , id : NodeId ) -> Abi {
859877 let parent = self . get_parent ( id) ;
860878 if let Some ( entry) = self . find_entry ( parent) {
@@ -868,6 +886,12 @@ impl<'hir> Map<'hir> {
868886 bug ! ( "expected foreign mod or inlined parent, found {}" , self . node_to_string( parent) )
869887 }
870888
889+ // FIXME(@ljedrz): replace the NodeId variant
890+ pub fn get_foreign_abi_by_hir_id ( & self , id : HirId ) -> Abi {
891+ let node_id = self . hir_to_node_id ( id) ;
892+ self . get_foreign_abi ( node_id)
893+ }
894+
871895 pub fn expect_item ( & self , id : NodeId ) -> & ' hir Item {
872896 match self . find ( id) { // read recorded by `find`
873897 Some ( Node :: Item ( item) ) => item,
@@ -888,6 +912,18 @@ impl<'hir> Map<'hir> {
888912 }
889913 }
890914
915+ // FIXME(@ljedrz): replace the NodeId variant
916+ pub fn expect_impl_item_by_hir_id ( & self , id : HirId ) -> & ' hir ImplItem {
917+ let node_id = self . hir_to_node_id ( id) ;
918+ self . expect_impl_item ( node_id)
919+ }
920+
921+ // FIXME(@ljedrz): replace the NodeId variant
922+ pub fn expect_trait_item_by_hir_id ( & self , id : HirId ) -> & ' hir TraitItem {
923+ let node_id = self . hir_to_node_id ( id) ;
924+ self . expect_trait_item ( node_id)
925+ }
926+
891927 pub fn expect_trait_item ( & self , id : NodeId ) -> & ' hir TraitItem {
892928 match self . find ( id) {
893929 Some ( Node :: TraitItem ( item) ) => item,
@@ -931,6 +967,12 @@ impl<'hir> Map<'hir> {
931967 }
932968 }
933969
970+ // FIXME(@ljedrz): replace the NodeId variant
971+ pub fn expect_expr_by_hir_id ( & self , id : HirId ) -> & ' hir Expr {
972+ let node_id = self . hir_to_node_id ( id) ;
973+ self . expect_expr ( node_id)
974+ }
975+
934976 /// Returns the name associated with the given NodeId's AST.
935977 pub fn name ( & self , id : NodeId ) -> Name {
936978 match self . get ( id) {
@@ -948,6 +990,12 @@ impl<'hir> Map<'hir> {
948990 }
949991 }
950992
993+ // FIXME(@ljedrz): replace the NodeId variant
994+ pub fn name_by_hir_id ( & self , id : HirId ) -> Name {
995+ let node_id = self . hir_to_node_id ( id) ;
996+ self . name ( node_id)
997+ }
998+
951999 /// Given a node ID, get a list of attributes associated with the AST
9521000 /// corresponding to the Node ID
9531001 pub fn attrs ( & self , id : NodeId ) -> & ' hir [ ast:: Attribute ] {
@@ -970,6 +1018,12 @@ impl<'hir> Map<'hir> {
9701018 attrs. unwrap_or ( & [ ] )
9711019 }
9721020
1021+ // FIXME(@ljedrz): replace the NodeId variant
1022+ pub fn attrs_by_hir_id ( & self , id : HirId ) -> & ' hir [ ast:: Attribute ] {
1023+ let node_id = self . hir_to_node_id ( id) ;
1024+ self . attrs ( node_id)
1025+ }
1026+
9731027 /// Returns an iterator that yields the node id's with paths that
9741028 /// match `parts`. (Requires `parts` is non-empty.)
9751029 ///
@@ -1019,6 +1073,12 @@ impl<'hir> Map<'hir> {
10191073 }
10201074 }
10211075
1076+ // FIXME(@ljedrz): replace the NodeId variant
1077+ pub fn span_by_hir_id ( & self , id : HirId ) -> Span {
1078+ let node_id = self . hir_to_node_id ( id) ;
1079+ self . span ( node_id)
1080+ }
1081+
10221082 pub fn span_if_local ( & self , id : DefId ) -> Option < Span > {
10231083 self . as_local_node_id ( id) . map ( |id| self . span ( id) )
10241084 }
0 commit comments