@@ -291,8 +291,8 @@ impl<'hir> Map<'hir> {
291
291
self . definitions . def_index_to_hir_id ( def_id. to_def_id ( ) . index )
292
292
}
293
293
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 ) {
296
296
node
297
297
} else {
298
298
return None
@@ -347,7 +347,7 @@ impl<'hir> Map<'hir> {
347
347
if variant_data. ctor_hir_id ( ) . is_none ( ) {
348
348
return None ;
349
349
}
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 ) ) {
351
351
Some ( Node :: Item ( ..) ) => def:: CtorOf :: Struct ,
352
352
Some ( Node :: Variant ( ..) ) => def:: CtorOf :: Variant ,
353
353
_ => unreachable ! ( ) ,
@@ -458,7 +458,7 @@ impl<'hir> Map<'hir> {
458
458
}
459
459
460
460
pub fn body_owner_kind ( & self , id : HirId ) -> BodyOwnerKind {
461
- match self . get_by_hir_id ( id) {
461
+ match self . get ( id) {
462
462
Node :: Item ( & Item { node : ItemKind :: Const ( ..) , .. } ) |
463
463
Node :: TraitItem ( & TraitItem { node : TraitItemKind :: Const ( ..) , .. } ) |
464
464
Node :: ImplItem ( & ImplItem { node : ImplItemKind :: Const ( ..) , .. } ) |
@@ -482,7 +482,7 @@ impl<'hir> Map<'hir> {
482
482
}
483
483
484
484
pub fn ty_param_owner ( & self , id : HirId ) -> HirId {
485
- match self . get_by_hir_id ( id) {
485
+ match self . get ( id) {
486
486
Node :: Item ( & Item { node : ItemKind :: Trait ( ..) , .. } ) |
487
487
Node :: Item ( & Item { node : ItemKind :: TraitAlias ( ..) , .. } ) => id,
488
488
Node :: GenericParam ( _) => self . get_parent_node_by_hir_id ( id) ,
@@ -491,7 +491,7 @@ impl<'hir> Map<'hir> {
491
491
}
492
492
493
493
pub fn ty_param_name ( & self , id : HirId ) -> Name {
494
- match self . get_by_hir_id ( id) {
494
+ match self . get ( id) {
495
495
Node :: Item ( & Item { node : ItemKind :: Trait ( ..) , .. } ) |
496
496
Node :: Item ( & Item { node : ItemKind :: TraitAlias ( ..) , .. } ) => kw:: SelfUpper ,
497
497
Node :: GenericParam ( param) => param. name . ident ( ) . name ,
@@ -561,20 +561,14 @@ impl<'hir> Map<'hir> {
561
561
}
562
562
563
563
/// 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 > {
571
565
// read recorded by `find`
572
566
self . find_by_hir_id ( id) . unwrap_or_else ( ||
573
567
bug ! ( "couldn't find hir id {} in the HIR map" , id) )
574
568
}
575
569
576
570
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`
578
572
}
579
573
580
574
pub fn get_generics ( & self , id : DefId ) -> Option < & ' hir Generics > {
@@ -846,7 +840,7 @@ impl<'hir> Map<'hir> {
846
840
if scope == CRATE_HIR_ID {
847
841
return Some ( CRATE_HIR_ID ) ;
848
842
}
849
- match self . get_by_hir_id ( scope) {
843
+ match self . get ( scope) {
850
844
Node :: Item ( i) => {
851
845
match i. node {
852
846
ItemKind :: Existential ( ExistTy { impl_trait_fn : None , .. } ) => { }
@@ -927,28 +921,15 @@ impl<'hir> Map<'hir> {
927
921
}
928
922
}
929
923
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 {
937
925
match self . find_by_hir_id ( id) { // read recorded by find
938
926
Some ( Node :: Expr ( expr) ) => expr,
939
927
_ => bug ! ( "expected expr, found {}" , self . node_to_string( id) )
940
928
}
941
929
}
942
930
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) {
952
933
Node :: Item ( i) => i. ident . name ,
953
934
Node :: ForeignItem ( fi) => fi. ident . name ,
954
935
Node :: ImplItem ( ii) => ii. ident . name ,
@@ -958,7 +939,7 @@ impl<'hir> Map<'hir> {
958
939
Node :: Lifetime ( lt) => lt. name . ident ( ) . name ,
959
940
Node :: GenericParam ( param) => param. name . ident ( ) . name ,
960
941
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) ) ,
962
943
_ => bug ! ( "no name for {}" , self . node_to_string( id) )
963
944
}
964
945
}
@@ -1080,7 +1061,7 @@ impl<'hir> Map<'hir> {
1080
1061
}
1081
1062
1082
1063
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) ) )
1084
1065
}
1085
1066
}
1086
1067
@@ -1407,8 +1388,8 @@ fn hir_id_to_string(map: &Map<'_>, id: HirId, include_id: bool) -> String {
1407
1388
1408
1389
pub fn provide ( providers : & mut Providers < ' _ > ) {
1409
1390
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 )
1412
1393
} else {
1413
1394
bug ! ( "calling local def_kind query provider for upstream DefId: {:?}" ,
1414
1395
def_id
0 commit comments