@@ -286,21 +286,11 @@ impl<'hir> Map<'hir> {
286
286
self . definitions . def_index_to_hir_id ( def_index)
287
287
}
288
288
289
- #[ inline]
290
- pub fn def_index_to_node_id ( & self , def_index : DefIndex ) -> NodeId {
291
- self . definitions . def_index_to_node_id ( def_index)
292
- }
293
-
294
289
#[ inline]
295
290
pub fn local_def_id_to_hir_id ( & self , def_id : LocalDefId ) -> HirId {
296
291
self . definitions . def_index_to_hir_id ( def_id. to_def_id ( ) . index )
297
292
}
298
293
299
- #[ inline]
300
- pub fn local_def_id_to_node_id ( & self , def_id : LocalDefId ) -> NodeId {
301
- self . definitions . as_local_node_id ( def_id. to_def_id ( ) ) . unwrap ( )
302
- }
303
-
304
294
fn def_kind ( & self , node_id : NodeId ) -> Option < DefKind > {
305
295
let node = if let Some ( node) = self . find ( node_id) {
306
296
node
@@ -422,12 +412,6 @@ impl<'hir> Map<'hir> {
422
412
self . forest . krate . body ( id)
423
413
}
424
414
425
- pub fn fn_decl ( & self , node_id : ast:: NodeId ) -> Option < FnDecl > {
426
- let hir_id = self . node_to_hir_id ( node_id) ;
427
- self . fn_decl_by_hir_id ( hir_id)
428
- }
429
-
430
- // FIXME(@ljedrz): replace the `NodeId` variant.
431
415
pub fn fn_decl_by_hir_id ( & self , hir_id : HirId ) -> Option < FnDecl > {
432
416
if let Some ( entry) = self . find_entry ( hir_id) {
433
417
entry. fn_decl ( ) . cloned ( )
@@ -439,24 +423,18 @@ impl<'hir> Map<'hir> {
439
423
/// Returns the `NodeId` that corresponds to the definition of
440
424
/// which this is the body of, i.e., a `fn`, `const` or `static`
441
425
/// item (possibly associated), a closure, or a `hir::AnonConst`.
442
- pub fn body_owner ( & self , BodyId { hir_id } : BodyId ) -> NodeId {
426
+ pub fn body_owner ( & self , BodyId { hir_id } : BodyId ) -> HirId {
443
427
let parent = self . get_parent_node_by_hir_id ( hir_id) ;
444
428
assert ! ( self . lookup( parent) . map_or( false , |e| e. is_body_owner( hir_id) ) ) ;
445
- self . hir_to_node_id ( parent)
429
+ parent
446
430
}
447
431
448
432
pub fn body_owner_def_id ( & self , id : BodyId ) -> DefId {
449
- self . local_def_id ( self . body_owner ( id) )
433
+ self . local_def_id_from_hir_id ( self . body_owner ( id) )
450
434
}
451
435
452
- /// Given a `NodeId `, returns the `BodyId` associated with it,
436
+ /// Given a `HirId `, returns the `BodyId` associated with it,
453
437
/// if the node is a body owner, otherwise returns `None`.
454
- pub fn maybe_body_owned_by ( & self , id : NodeId ) -> Option < BodyId > {
455
- let hir_id = self . node_to_hir_id ( id) ;
456
- self . maybe_body_owned_by_by_hir_id ( hir_id)
457
- }
458
-
459
- // FIXME(@ljedrz): replace the `NodeId` variant.
460
438
pub fn maybe_body_owned_by_by_hir_id ( & self , hir_id : HirId ) -> Option < BodyId > {
461
439
if let Some ( entry) = self . find_entry ( hir_id) {
462
440
if self . dep_graph . is_fully_enabled ( ) {
@@ -479,12 +457,6 @@ impl<'hir> Map<'hir> {
479
457
} )
480
458
}
481
459
482
- pub fn body_owner_kind ( & self , id : NodeId ) -> BodyOwnerKind {
483
- let hir_id = self . node_to_hir_id ( id) ;
484
- self . body_owner_kind_by_hir_id ( hir_id)
485
- }
486
-
487
- // FIXME(@ljedrz): replace the `NodeId` variant.
488
460
pub fn body_owner_kind_by_hir_id ( & self , id : HirId ) -> BodyOwnerKind {
489
461
match self . get_by_hir_id ( id) {
490
462
Node :: Item ( & Item { node : ItemKind :: Const ( ..) , .. } ) |
@@ -793,17 +765,10 @@ impl<'hir> Map<'hir> {
793
765
self . walk_parent_nodes ( id, match_fn, match_non_returning_block) . ok ( )
794
766
}
795
767
796
- /// Retrieves the `NodeId ` for `id`'s parent item, or `id` itself if no
768
+ /// Retrieves the `HirId ` for `id`'s parent item, or `id` itself if no
797
769
/// parent item is in this map. The "parent item" is the closest parent node
798
770
/// in the HIR which is recorded by the map and is an item, either an item
799
771
/// in a module, trait, or impl.
800
- pub fn get_parent ( & self , id : NodeId ) -> NodeId {
801
- let hir_id = self . node_to_hir_id ( id) ;
802
- let parent_hir_id = self . get_parent_item ( hir_id) ;
803
- self . hir_to_node_id ( parent_hir_id)
804
- }
805
-
806
- // FIXME(@ljedrz): replace the `NodeId` variant.
807
772
pub fn get_parent_item ( & self , hir_id : HirId ) -> HirId {
808
773
match self . walk_parent_nodes ( hir_id, |node| match * node {
809
774
Node :: Item ( _) |
@@ -819,12 +784,6 @@ impl<'hir> Map<'hir> {
819
784
820
785
/// Returns the `DefId` of `id`'s nearest module parent, or `id` itself if no
821
786
/// module parent is in this map.
822
- pub fn get_module_parent ( & self , id : NodeId ) -> DefId {
823
- let hir_id = self . node_to_hir_id ( id) ;
824
- self . get_module_parent_by_hir_id ( hir_id)
825
- }
826
-
827
- // FIXME(@ljedrz): replace the `NodeId` variant.
828
787
pub fn get_module_parent_by_hir_id ( & self , id : HirId ) -> DefId {
829
788
self . local_def_id_from_hir_id ( self . get_module_parent_node ( id) )
830
789
}
@@ -901,22 +860,10 @@ impl<'hir> Map<'hir> {
901
860
Some ( scope)
902
861
}
903
862
904
- pub fn get_parent_did ( & self , id : NodeId ) -> DefId {
905
- let hir_id = self . node_to_hir_id ( id) ;
906
- self . get_parent_did_by_hir_id ( hir_id)
907
- }
908
-
909
- // FIXME(@ljedrz): replace the `NodeId` variant.
910
863
pub fn get_parent_did_by_hir_id ( & self , id : HirId ) -> DefId {
911
864
self . local_def_id_from_hir_id ( self . get_parent_item ( id) )
912
865
}
913
866
914
- pub fn get_foreign_abi ( & self , id : NodeId ) -> Abi {
915
- let hir_id = self . node_to_hir_id ( id) ;
916
- self . get_foreign_abi_by_hir_id ( hir_id)
917
- }
918
-
919
- // FIXME(@ljedrz): replace the `NodeId` variant.
920
867
pub fn get_foreign_abi_by_hir_id ( & self , hir_id : HirId ) -> Abi {
921
868
let parent = self . get_parent_item ( hir_id) ;
922
869
if let Some ( entry) = self . find_entry ( parent) {
@@ -930,12 +877,6 @@ impl<'hir> Map<'hir> {
930
877
bug ! ( "expected foreign mod or inlined parent, found {}" , self . hir_to_string( parent) )
931
878
}
932
879
933
- pub fn expect_item ( & self , id : NodeId ) -> & ' hir Item {
934
- let hir_id = self . node_to_hir_id ( id) ;
935
- self . expect_item_by_hir_id ( hir_id)
936
- }
937
-
938
- // FIXME(@ljedrz): replace the `NodeId` variant.
939
880
pub fn expect_item_by_hir_id ( & self , id : HirId ) -> & ' hir Item {
940
881
match self . find_by_hir_id ( id) { // read recorded by `find`
941
882
Some ( Node :: Item ( item) ) => item,
@@ -1024,12 +965,6 @@ impl<'hir> Map<'hir> {
1024
965
1025
966
/// Given a node ID, gets a list of attributes associated with the AST
1026
967
/// corresponding to the node-ID.
1027
- pub fn attrs ( & self , id : NodeId ) -> & ' hir [ ast:: Attribute ] {
1028
- let hir_id = self . node_to_hir_id ( id) ;
1029
- self . attrs_by_hir_id ( hir_id)
1030
- }
1031
-
1032
- // FIXME(@ljedrz): replace the `NodeId` variant.
1033
968
pub fn attrs_by_hir_id ( & self , id : HirId ) -> & ' hir [ ast:: Attribute ] {
1034
969
self . read ( id) ; // reveals attributes on the node
1035
970
let attrs = match self . find_entry ( id) . map ( |entry| entry. node ) {
@@ -1093,12 +1028,6 @@ impl<'hir> Map<'hir> {
1093
1028
} )
1094
1029
}
1095
1030
1096
- pub fn span ( & self , id : NodeId ) -> Span {
1097
- let hir_id = self . node_to_hir_id ( id) ;
1098
- self . span_by_hir_id ( hir_id)
1099
- }
1100
-
1101
- // FIXME(@ljedrz): replace the `NodeId` variant.
1102
1031
pub fn span_by_hir_id ( & self , hir_id : HirId ) -> Span {
1103
1032
self . read ( hir_id) ; // reveals span from node
1104
1033
match self . find_entry ( hir_id) . map ( |entry| entry. node ) {
@@ -1139,32 +1068,17 @@ impl<'hir> Map<'hir> {
1139
1068
}
1140
1069
1141
1070
pub fn span_if_local ( & self , id : DefId ) -> Option < Span > {
1142
- self . as_local_node_id ( id) . map ( |id| self . span ( id) )
1071
+ self . as_local_hir_id ( id) . map ( |id| self . span_by_hir_id ( id) )
1143
1072
}
1144
1073
1145
- pub fn node_to_string ( & self , id : NodeId ) -> String {
1146
- hir_id_to_string ( self , self . node_to_hir_id ( id) , true )
1147
- }
1148
-
1149
- // FIXME(@ljedrz): replace the `NodeId` variant.
1150
1074
pub fn hir_to_string ( & self , id : HirId ) -> String {
1151
1075
hir_id_to_string ( self , id, true )
1152
1076
}
1153
1077
1154
- pub fn node_to_user_string ( & self , id : NodeId ) -> String {
1155
- hir_id_to_string ( self , self . node_to_hir_id ( id) , false )
1156
- }
1157
-
1158
- // FIXME(@ljedrz): replace the `NodeId` variant.
1159
1078
pub fn hir_to_user_string ( & self , id : HirId ) -> String {
1160
1079
hir_id_to_string ( self , id, false )
1161
1080
}
1162
1081
1163
- pub fn node_to_pretty_string ( & self , id : NodeId ) -> String {
1164
- print:: to_string ( self , |s| s. print_node ( self . get ( id) ) )
1165
- }
1166
-
1167
- // FIXME(@ljedrz): replace the `NodeId` variant.
1168
1082
pub fn hir_to_pretty_string ( & self , id : HirId ) -> String {
1169
1083
print:: to_string ( self , |s| s. print_node ( self . get_by_hir_id ( id) ) )
1170
1084
}
0 commit comments