@@ -401,6 +401,12 @@ impl<'hir> Map<'hir> {
401
401
}
402
402
}
403
403
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
+
404
410
fn entry_count ( & self ) -> usize {
405
411
self . map . len ( )
406
412
}
@@ -445,6 +451,12 @@ impl<'hir> Map<'hir> {
445
451
}
446
452
}
447
453
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
+
448
460
/// Returns the `NodeId` that corresponds to the definition of
449
461
/// which this is the body of, i.e., a `fn`, `const` or `static`
450
462
/// item (possibly associated), a closure, or a `hir::AnonConst`.
@@ -855,6 +867,12 @@ impl<'hir> Map<'hir> {
855
867
self . local_def_id ( self . get_parent ( id) )
856
868
}
857
869
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
+
858
876
pub fn get_foreign_abi ( & self , id : NodeId ) -> Abi {
859
877
let parent = self . get_parent ( id) ;
860
878
if let Some ( entry) = self . find_entry ( parent) {
@@ -868,6 +886,12 @@ impl<'hir> Map<'hir> {
868
886
bug ! ( "expected foreign mod or inlined parent, found {}" , self . node_to_string( parent) )
869
887
}
870
888
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
+
871
895
pub fn expect_item ( & self , id : NodeId ) -> & ' hir Item {
872
896
match self . find ( id) { // read recorded by `find`
873
897
Some ( Node :: Item ( item) ) => item,
@@ -888,6 +912,18 @@ impl<'hir> Map<'hir> {
888
912
}
889
913
}
890
914
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
+
891
927
pub fn expect_trait_item ( & self , id : NodeId ) -> & ' hir TraitItem {
892
928
match self . find ( id) {
893
929
Some ( Node :: TraitItem ( item) ) => item,
@@ -931,6 +967,12 @@ impl<'hir> Map<'hir> {
931
967
}
932
968
}
933
969
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
+
934
976
/// Returns the name associated with the given NodeId's AST.
935
977
pub fn name ( & self , id : NodeId ) -> Name {
936
978
match self . get ( id) {
@@ -948,6 +990,12 @@ impl<'hir> Map<'hir> {
948
990
}
949
991
}
950
992
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
+
951
999
/// Given a node ID, get a list of attributes associated with the AST
952
1000
/// corresponding to the Node ID
953
1001
pub fn attrs ( & self , id : NodeId ) -> & ' hir [ ast:: Attribute ] {
@@ -970,6 +1018,12 @@ impl<'hir> Map<'hir> {
970
1018
attrs. unwrap_or ( & [ ] )
971
1019
}
972
1020
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
+
973
1027
/// Returns an iterator that yields the node id's with paths that
974
1028
/// match `parts`. (Requires `parts` is non-empty.)
975
1029
///
@@ -1019,6 +1073,12 @@ impl<'hir> Map<'hir> {
1019
1073
}
1020
1074
}
1021
1075
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
+
1022
1082
pub fn span_if_local ( & self , id : DefId ) -> Option < Span > {
1023
1083
self . as_local_node_id ( id) . map ( |id| self . span ( id) )
1024
1084
}
0 commit comments