@@ -291,8 +291,8 @@ impl<'hir> Map<'hir> {
291291 self . definitions . def_index_to_hir_id ( def_id. to_def_id ( ) . index )
292292 }
293293
294- fn def_kind ( & self , node_id : NodeId ) -> Option < DefKind > {
295- let node = if let Some ( node) = self . find ( node_id ) {
294+ fn def_kind ( & self , hir_id : HirId ) -> Option < DefKind > {
295+ let node = if let Some ( node) = self . find_by_hir_id ( hir_id ) {
296296 node
297297 } else {
298298 return None
@@ -347,7 +347,7 @@ impl<'hir> Map<'hir> {
347347 if variant_data. ctor_hir_id ( ) . is_none ( ) {
348348 return None ;
349349 }
350- let ctor_of = match self . find ( self . get_parent_node ( node_id ) ) {
350+ let ctor_of = match self . find_by_hir_id ( self . get_parent_node_by_hir_id ( hir_id ) ) {
351351 Some ( Node :: Item ( ..) ) => def:: CtorOf :: Struct ,
352352 Some ( Node :: Variant ( ..) ) => def:: CtorOf :: Variant ,
353353 _ => unreachable ! ( ) ,
@@ -458,7 +458,7 @@ impl<'hir> Map<'hir> {
458458 }
459459
460460 pub fn body_owner_kind ( & self , id : HirId ) -> BodyOwnerKind {
461- match self . get_by_hir_id ( id) {
461+ match self . get ( id) {
462462 Node :: Item ( & Item { node : ItemKind :: Const ( ..) , .. } ) |
463463 Node :: TraitItem ( & TraitItem { node : TraitItemKind :: Const ( ..) , .. } ) |
464464 Node :: ImplItem ( & ImplItem { node : ImplItemKind :: Const ( ..) , .. } ) |
@@ -482,7 +482,7 @@ impl<'hir> Map<'hir> {
482482 }
483483
484484 pub fn ty_param_owner ( & self , id : HirId ) -> HirId {
485- match self . get_by_hir_id ( id) {
485+ match self . get ( id) {
486486 Node :: Item ( & Item { node : ItemKind :: Trait ( ..) , .. } ) |
487487 Node :: Item ( & Item { node : ItemKind :: TraitAlias ( ..) , .. } ) => id,
488488 Node :: GenericParam ( _) => self . get_parent_node_by_hir_id ( id) ,
@@ -491,7 +491,7 @@ impl<'hir> Map<'hir> {
491491 }
492492
493493 pub fn ty_param_name ( & self , id : HirId ) -> Name {
494- match self . get_by_hir_id ( id) {
494+ match self . get ( id) {
495495 Node :: Item ( & Item { node : ItemKind :: Trait ( ..) , .. } ) |
496496 Node :: Item ( & Item { node : ItemKind :: TraitAlias ( ..) , .. } ) => kw:: SelfUpper ,
497497 Node :: GenericParam ( param) => param. name . ident ( ) . name ,
@@ -561,20 +561,14 @@ impl<'hir> Map<'hir> {
561561 }
562562
563563 /// Retrieves the `Node` corresponding to `id`, panicking if it cannot be found.
564- pub fn get ( & self , id : NodeId ) -> Node < ' hir > {
565- let hir_id = self . node_to_hir_id ( id) ;
566- self . get_by_hir_id ( hir_id)
567- }
568-
569- // FIXME(@ljedrz): replace the `NodeId` variant.
570- pub fn get_by_hir_id ( & self , id : HirId ) -> Node < ' hir > {
564+ pub fn get ( & self , id : HirId ) -> Node < ' hir > {
571565 // read recorded by `find`
572566 self . find_by_hir_id ( id) . unwrap_or_else ( ||
573567 bug ! ( "couldn't find hir id {} in the HIR map" , id) )
574568 }
575569
576570 pub fn get_if_local ( & self , id : DefId ) -> Option < Node < ' hir > > {
577- self . as_local_node_id ( id) . map ( |id| self . get ( id) ) // read recorded by `get`
571+ self . as_local_hir_id ( id) . map ( |id| self . get ( id) ) // read recorded by `get`
578572 }
579573
580574 pub fn get_generics ( & self , id : DefId ) -> Option < & ' hir Generics > {
@@ -846,7 +840,7 @@ impl<'hir> Map<'hir> {
846840 if scope == CRATE_HIR_ID {
847841 return Some ( CRATE_HIR_ID ) ;
848842 }
849- match self . get_by_hir_id ( scope) {
843+ match self . get ( scope) {
850844 Node :: Item ( i) => {
851845 match i. node {
852846 ItemKind :: Existential ( ExistTy { impl_trait_fn : None , .. } ) => { }
@@ -927,28 +921,15 @@ impl<'hir> Map<'hir> {
927921 }
928922 }
929923
930- pub fn expect_expr ( & self , id : NodeId ) -> & ' hir Expr {
931- let hir_id = self . node_to_hir_id ( id) ;
932- self . expect_expr_by_hir_id ( hir_id)
933- }
934-
935- // FIXME(@ljedrz): replace the `NodeId` variant.
936- pub fn expect_expr_by_hir_id ( & self , id : HirId ) -> & ' hir Expr {
924+ pub fn expect_expr ( & self , id : HirId ) -> & ' hir Expr {
937925 match self . find_by_hir_id ( id) { // read recorded by find
938926 Some ( Node :: Expr ( expr) ) => expr,
939927 _ => bug ! ( "expected expr, found {}" , self . node_to_string( id) )
940928 }
941929 }
942930
943- /// Returns the name associated with the given `NodeId`'s AST.
944- pub fn name ( & self , id : NodeId ) -> Name {
945- let hir_id = self . node_to_hir_id ( id) ;
946- self . name_by_hir_id ( hir_id)
947- }
948-
949- // FIXME(@ljedrz): replace the `NodeId` variant.
950- pub fn name_by_hir_id ( & self , id : HirId ) -> Name {
951- match self . get_by_hir_id ( id) {
931+ pub fn name ( & self , id : HirId ) -> Name {
932+ match self . get ( id) {
952933 Node :: Item ( i) => i. ident . name ,
953934 Node :: ForeignItem ( fi) => fi. ident . name ,
954935 Node :: ImplItem ( ii) => ii. ident . name ,
@@ -958,7 +939,7 @@ impl<'hir> Map<'hir> {
958939 Node :: Lifetime ( lt) => lt. name . ident ( ) . name ,
959940 Node :: GenericParam ( param) => param. name . ident ( ) . name ,
960941 Node :: Binding ( & Pat { node : PatKind :: Binding ( _, _, l, _) , .. } ) => l. name ,
961- Node :: Ctor ( ..) => self . name_by_hir_id ( self . get_parent_item ( id) ) ,
942+ Node :: Ctor ( ..) => self . name ( self . get_parent_item ( id) ) ,
962943 _ => bug ! ( "no name for {}" , self . node_to_string( id) )
963944 }
964945 }
@@ -1080,7 +1061,7 @@ impl<'hir> Map<'hir> {
10801061 }
10811062
10821063 pub fn hir_to_pretty_string ( & self , id : HirId ) -> String {
1083- print:: to_string ( self , |s| s. print_node ( self . get_by_hir_id ( id) ) )
1064+ print:: to_string ( self , |s| s. print_node ( self . get ( id) ) )
10841065 }
10851066}
10861067
@@ -1407,8 +1388,8 @@ fn hir_id_to_string(map: &Map<'_>, id: HirId, include_id: bool) -> String {
14071388
14081389pub fn provide ( providers : & mut Providers < ' _ > ) {
14091390 providers. def_kind = |tcx, def_id| {
1410- if let Some ( node_id ) = tcx. hir ( ) . as_local_node_id ( def_id) {
1411- tcx. hir ( ) . def_kind ( node_id )
1391+ if let Some ( hir_id ) = tcx. hir ( ) . as_local_hir_id ( def_id) {
1392+ tcx. hir ( ) . def_kind ( hir_id )
14121393 } else {
14131394 bug ! ( "calling local def_kind query provider for upstream DefId: {:?}" ,
14141395 def_id
0 commit comments