@@ -286,21 +286,11 @@ impl<'hir> Map<'hir> {
286286 self . definitions . def_index_to_hir_id ( def_index)
287287 }
288288
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-
294289 #[ inline]
295290 pub fn local_def_id_to_hir_id ( & self , def_id : LocalDefId ) -> HirId {
296291 self . definitions . def_index_to_hir_id ( def_id. to_def_id ( ) . index )
297292 }
298293
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-
304294 fn def_kind ( & self , node_id : NodeId ) -> Option < DefKind > {
305295 let node = if let Some ( node) = self . find ( node_id) {
306296 node
@@ -422,12 +412,6 @@ impl<'hir> Map<'hir> {
422412 self . forest . krate . body ( id)
423413 }
424414
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.
431415 pub fn fn_decl_by_hir_id ( & self , hir_id : HirId ) -> Option < FnDecl > {
432416 if let Some ( entry) = self . find_entry ( hir_id) {
433417 entry. fn_decl ( ) . cloned ( )
@@ -439,24 +423,18 @@ impl<'hir> Map<'hir> {
439423 /// Returns the `NodeId` that corresponds to the definition of
440424 /// which this is the body of, i.e., a `fn`, `const` or `static`
441425 /// 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 {
443427 let parent = self . get_parent_node_by_hir_id ( hir_id) ;
444428 assert ! ( self . lookup( parent) . map_or( false , |e| e. is_body_owner( hir_id) ) ) ;
445- self . hir_to_node_id ( parent)
429+ parent
446430 }
447431
448432 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) )
450434 }
451435
452- /// Given a `NodeId `, returns the `BodyId` associated with it,
436+ /// Given a `HirId `, returns the `BodyId` associated with it,
453437 /// 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.
460438 pub fn maybe_body_owned_by_by_hir_id ( & self , hir_id : HirId ) -> Option < BodyId > {
461439 if let Some ( entry) = self . find_entry ( hir_id) {
462440 if self . dep_graph . is_fully_enabled ( ) {
@@ -479,12 +457,6 @@ impl<'hir> Map<'hir> {
479457 } )
480458 }
481459
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.
488460 pub fn body_owner_kind_by_hir_id ( & self , id : HirId ) -> BodyOwnerKind {
489461 match self . get_by_hir_id ( id) {
490462 Node :: Item ( & Item { node : ItemKind :: Const ( ..) , .. } ) |
@@ -793,17 +765,10 @@ impl<'hir> Map<'hir> {
793765 self . walk_parent_nodes ( id, match_fn, match_non_returning_block) . ok ( )
794766 }
795767
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
797769 /// parent item is in this map. The "parent item" is the closest parent node
798770 /// in the HIR which is recorded by the map and is an item, either an item
799771 /// 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.
807772 pub fn get_parent_item ( & self , hir_id : HirId ) -> HirId {
808773 match self . walk_parent_nodes ( hir_id, |node| match * node {
809774 Node :: Item ( _) |
@@ -819,12 +784,6 @@ impl<'hir> Map<'hir> {
819784
820785 /// Returns the `DefId` of `id`'s nearest module parent, or `id` itself if no
821786 /// 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.
828787 pub fn get_module_parent_by_hir_id ( & self , id : HirId ) -> DefId {
829788 self . local_def_id_from_hir_id ( self . get_module_parent_node ( id) )
830789 }
@@ -901,22 +860,10 @@ impl<'hir> Map<'hir> {
901860 Some ( scope)
902861 }
903862
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.
910863 pub fn get_parent_did_by_hir_id ( & self , id : HirId ) -> DefId {
911864 self . local_def_id_from_hir_id ( self . get_parent_item ( id) )
912865 }
913866
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.
920867 pub fn get_foreign_abi_by_hir_id ( & self , hir_id : HirId ) -> Abi {
921868 let parent = self . get_parent_item ( hir_id) ;
922869 if let Some ( entry) = self . find_entry ( parent) {
@@ -930,12 +877,6 @@ impl<'hir> Map<'hir> {
930877 bug ! ( "expected foreign mod or inlined parent, found {}" , self . hir_to_string( parent) )
931878 }
932879
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.
939880 pub fn expect_item_by_hir_id ( & self , id : HirId ) -> & ' hir Item {
940881 match self . find_by_hir_id ( id) { // read recorded by `find`
941882 Some ( Node :: Item ( item) ) => item,
@@ -1024,12 +965,6 @@ impl<'hir> Map<'hir> {
1024965
1025966 /// Given a node ID, gets a list of attributes associated with the AST
1026967 /// 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.
1033968 pub fn attrs_by_hir_id ( & self , id : HirId ) -> & ' hir [ ast:: Attribute ] {
1034969 self . read ( id) ; // reveals attributes on the node
1035970 let attrs = match self . find_entry ( id) . map ( |entry| entry. node ) {
@@ -1093,12 +1028,6 @@ impl<'hir> Map<'hir> {
10931028 } )
10941029 }
10951030
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.
11021031 pub fn span_by_hir_id ( & self , hir_id : HirId ) -> Span {
11031032 self . read ( hir_id) ; // reveals span from node
11041033 match self . find_entry ( hir_id) . map ( |entry| entry. node ) {
@@ -1139,32 +1068,17 @@ impl<'hir> Map<'hir> {
11391068 }
11401069
11411070 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) )
11431072 }
11441073
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.
11501074 pub fn hir_to_string ( & self , id : HirId ) -> String {
11511075 hir_id_to_string ( self , id, true )
11521076 }
11531077
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.
11591078 pub fn hir_to_user_string ( & self , id : HirId ) -> String {
11601079 hir_id_to_string ( self , id, false )
11611080 }
11621081
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.
11681082 pub fn hir_to_pretty_string ( & self , id : HirId ) -> String {
11691083 print:: to_string ( self , |s| s. print_node ( self . get_by_hir_id ( id) ) )
11701084 }
0 commit comments