@@ -292,7 +292,7 @@ impl<'hir> Map<'hir> {
292
292
}
293
293
294
294
fn def_kind ( & self , hir_id : HirId ) -> Option < DefKind > {
295
- let node = if let Some ( node) = self . find_by_hir_id ( hir_id) {
295
+ let node = if let Some ( node) = self . find ( 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_by_hir_id ( self . get_parent_node ( hir_id) ) {
350
+ let ctor_of = match self . find ( self . get_parent_node ( hir_id) ) {
351
351
Some ( Node :: Item ( ..) ) => def:: CtorOf :: Struct ,
352
352
Some ( Node :: Variant ( ..) ) => def:: CtorOf :: Variant ,
353
353
_ => unreachable ! ( ) ,
@@ -563,7 +563,7 @@ impl<'hir> Map<'hir> {
563
563
/// Retrieves the `Node` corresponding to `id`, panicking if it cannot be found.
564
564
pub fn get ( & self , id : HirId ) -> Node < ' hir > {
565
565
// read recorded by `find`
566
- self . find_by_hir_id ( id) . unwrap_or_else ( ||
566
+ self . find ( id) . unwrap_or_else ( ||
567
567
bug ! ( "couldn't find hir id {} in the HIR map" , id) )
568
568
}
569
569
@@ -595,7 +595,7 @@ impl<'hir> Map<'hir> {
595
595
}
596
596
597
597
/// Retrieves the `Node` corresponding to `id`, returning `None` if cannot be found.
598
- pub fn find_by_hir_id ( & self , hir_id : HirId ) -> Option < Node < ' hir > > {
598
+ pub fn find ( & self , hir_id : HirId ) -> Option < Node < ' hir > > {
599
599
let result = self . find_entry ( hir_id) . and_then ( |entry| {
600
600
if let Node :: Crate = entry. node {
601
601
None
@@ -634,11 +634,11 @@ impl<'hir> Map<'hir> {
634
634
/// Check if the node is an argument. An argument is a local variable whose
635
635
/// immediate parent is an item or a closure.
636
636
pub fn is_argument ( & self , id : HirId ) -> bool {
637
- match self . find_by_hir_id ( id) {
637
+ match self . find ( id) {
638
638
Some ( Node :: Binding ( _) ) => ( ) ,
639
639
_ => return false ,
640
640
}
641
- match self . find_by_hir_id ( self . get_parent_node ( id) ) {
641
+ match self . find ( self . get_parent_node ( id) ) {
642
642
Some ( Node :: Item ( _) ) |
643
643
Some ( Node :: TraitItem ( _) ) |
644
644
Some ( Node :: ImplItem ( _) ) => true ,
@@ -859,28 +859,28 @@ impl<'hir> Map<'hir> {
859
859
}
860
860
861
861
pub fn expect_item ( & self , id : HirId ) -> & ' hir Item {
862
- match self . find_by_hir_id ( id) { // read recorded by `find`
862
+ match self . find ( id) { // read recorded by `find`
863
863
Some ( Node :: Item ( item) ) => item,
864
864
_ => bug ! ( "expected item, found {}" , self . node_to_string( id) )
865
865
}
866
866
}
867
867
868
868
pub fn expect_impl_item ( & self , id : HirId ) -> & ' hir ImplItem {
869
- match self . find_by_hir_id ( id) {
869
+ match self . find ( id) {
870
870
Some ( Node :: ImplItem ( item) ) => item,
871
871
_ => bug ! ( "expected impl item, found {}" , self . node_to_string( id) )
872
872
}
873
873
}
874
874
875
875
pub fn expect_trait_item ( & self , id : HirId ) -> & ' hir TraitItem {
876
- match self . find_by_hir_id ( id) {
876
+ match self . find ( id) {
877
877
Some ( Node :: TraitItem ( item) ) => item,
878
878
_ => bug ! ( "expected trait item, found {}" , self . node_to_string( id) )
879
879
}
880
880
}
881
881
882
882
pub fn expect_variant_data ( & self , id : HirId ) -> & ' hir VariantData {
883
- match self . find_by_hir_id ( id) {
883
+ match self . find ( id) {
884
884
Some ( Node :: Item ( i) ) => {
885
885
match i. node {
886
886
ItemKind :: Struct ( ref struct_def, _) |
@@ -895,21 +895,21 @@ impl<'hir> Map<'hir> {
895
895
}
896
896
897
897
pub fn expect_variant ( & self , id : HirId ) -> & ' hir Variant {
898
- match self . find_by_hir_id ( id) {
898
+ match self . find ( id) {
899
899
Some ( Node :: Variant ( variant) ) => variant,
900
900
_ => bug ! ( "expected variant, found {}" , self . node_to_string( id) ) ,
901
901
}
902
902
}
903
903
904
904
pub fn expect_foreign_item ( & self , id : HirId ) -> & ' hir ForeignItem {
905
- match self . find_by_hir_id ( id) {
905
+ match self . find ( id) {
906
906
Some ( Node :: ForeignItem ( item) ) => item,
907
907
_ => bug ! ( "expected foreign item, found {}" , self . node_to_string( id) )
908
908
}
909
909
}
910
910
911
911
pub fn expect_expr ( & self , id : HirId ) -> & ' hir Expr {
912
- match self . find_by_hir_id ( id) { // read recorded by find
912
+ match self . find ( id) { // read recorded by find
913
913
Some ( Node :: Expr ( expr) ) => expr,
914
914
_ => bug ! ( "expected expr, found {}" , self . node_to_string( id) )
915
915
}
@@ -1015,7 +1015,7 @@ impl<'hir> Map<'hir> {
1015
1015
Some ( Node :: Pat ( pat) ) => pat. span ,
1016
1016
Some ( Node :: Arm ( arm) ) => arm. span ,
1017
1017
Some ( Node :: Block ( block) ) => block. span ,
1018
- Some ( Node :: Ctor ( ..) ) => match self . find_by_hir_id (
1018
+ Some ( Node :: Ctor ( ..) ) => match self . find (
1019
1019
self . get_parent_node ( hir_id) )
1020
1020
{
1021
1021
Some ( Node :: Item ( item) ) => item. span ,
@@ -1087,7 +1087,7 @@ impl<'a> NodesMatchingSuffix<'a> {
1087
1087
// chain, then returns `None`.
1088
1088
fn find_first_mod_parent < ' a > ( map : & ' a Map < ' _ > , mut id : HirId ) -> Option < ( HirId , Name ) > {
1089
1089
loop {
1090
- if let Node :: Item ( item) = map. find_by_hir_id ( id) ? {
1090
+ if let Node :: Item ( item) = map. find ( id) ? {
1091
1091
if item_is_mod ( & item) {
1092
1092
return Some ( ( id, item. ident . name ) )
1093
1093
}
@@ -1260,7 +1260,7 @@ fn hir_id_to_string(map: &Map<'_>, id: HirId, include_id: bool) -> String {
1260
1260
} )
1261
1261
} ;
1262
1262
1263
- match map. find_by_hir_id ( id) {
1263
+ match map. find ( id) {
1264
1264
Some ( Node :: Item ( item) ) => {
1265
1265
let item_str = match item. node {
1266
1266
ItemKind :: ExternCrate ( ..) => "extern crate" ,
0 commit comments