1
1
use self :: collector:: NodeCollector ;
2
2
pub use self :: def_collector:: { DefCollector , MacroInvocationData } ;
3
- pub use self :: definitions:: { Definitions , DefKey , DefPath , DefPathData ,
4
- DisambiguatedDefPathData , DefPathHash } ;
3
+ pub use self :: definitions:: {
4
+ Definitions , DefKey , DefPath , DefPathData , DisambiguatedDefPathData , DefPathHash
5
+ } ;
5
6
6
7
use crate :: dep_graph:: { DepGraph , DepNode , DepKind , DepNodeIndex } ;
7
8
@@ -238,7 +239,7 @@ impl<'hir> Map<'hir> {
238
239
} )
239
240
}
240
241
241
- // FIXME(@ljedrz): replace the NodeId variant
242
+ // FIXME(@ljedrz): replace the ` NodeId` variant.
242
243
#[ inline]
243
244
pub fn local_def_id_from_hir_id ( & self , hir_id : HirId ) -> DefId {
244
245
self . opt_local_def_id_from_hir_id ( hir_id) . unwrap_or_else ( || {
@@ -247,7 +248,7 @@ impl<'hir> Map<'hir> {
247
248
} )
248
249
}
249
250
250
- // FIXME(@ljedrz): replace the NodeId variant
251
+ // FIXME(@ljedrz): replace the ` NodeId` variant.
251
252
#[ inline]
252
253
pub fn opt_local_def_id_from_hir_id ( & self , hir_id : HirId ) -> Option < DefId > {
253
254
let node_id = self . hir_to_node_id ( hir_id) ;
@@ -264,7 +265,7 @@ impl<'hir> Map<'hir> {
264
265
self . definitions . as_local_node_id ( def_id)
265
266
}
266
267
267
- // FIXME(@ljedrz): replace the NodeId variant
268
+ // FIXME(@ljedrz): replace the ` NodeId` variant.
268
269
#[ inline]
269
270
pub fn as_local_hir_id ( & self , def_id : DefId ) -> Option < HirId > {
270
271
self . definitions . as_local_hir_id ( def_id)
@@ -426,7 +427,7 @@ impl<'hir> Map<'hir> {
426
427
self . fn_decl_by_hir_id ( hir_id)
427
428
}
428
429
429
- // FIXME(@ljedrz): replace the NodeId variant
430
+ // FIXME(@ljedrz): replace the ` NodeId` variant.
430
431
pub fn fn_decl_by_hir_id ( & self , hir_id : HirId ) -> Option < FnDecl > {
431
432
if let Some ( entry) = self . find_entry ( hir_id) {
432
433
entry. fn_decl ( ) . cloned ( )
@@ -455,7 +456,7 @@ impl<'hir> Map<'hir> {
455
456
self . maybe_body_owned_by_by_hir_id ( hir_id)
456
457
}
457
458
458
- // FIXME(@ljedrz): replace the NodeId variant
459
+ // FIXME(@ljedrz): replace the ` NodeId` variant.
459
460
pub fn maybe_body_owned_by_by_hir_id ( & self , hir_id : HirId ) -> Option < BodyId > {
460
461
if let Some ( entry) = self . find_entry ( hir_id) {
461
462
if self . dep_graph . is_fully_enabled ( ) {
@@ -483,7 +484,7 @@ impl<'hir> Map<'hir> {
483
484
self . body_owner_kind_by_hir_id ( hir_id)
484
485
}
485
486
486
- // FIXME(@ljedrz): replace the NodeId variant
487
+ // FIXME(@ljedrz): replace the ` NodeId` variant.
487
488
pub fn body_owner_kind_by_hir_id ( & self , id : HirId ) -> BodyOwnerKind {
488
489
match self . get_by_hir_id ( id) {
489
490
Node :: Item ( & Item { node : ItemKind :: Const ( ..) , .. } ) |
@@ -587,14 +588,13 @@ impl<'hir> Map<'hir> {
587
588
}
588
589
}
589
590
590
- /// Retrieve the Node corresponding to `id`, panicking if it cannot
591
- /// be found.
591
+ /// Retrieves the `Node` corresponding to `id`, panicking if it cannot be found.
592
592
pub fn get ( & self , id : NodeId ) -> Node < ' hir > {
593
593
let hir_id = self . node_to_hir_id ( id) ;
594
594
self . get_by_hir_id ( hir_id)
595
595
}
596
596
597
- // FIXME(@ljedrz): replace the NodeId variant
597
+ // FIXME(@ljedrz): replace the ` NodeId` variant.
598
598
pub fn get_by_hir_id ( & self , id : HirId ) -> Node < ' hir > {
599
599
// read recorded by `find`
600
600
self . find_by_hir_id ( id) . unwrap_or_else ( ||
@@ -634,7 +634,7 @@ impl<'hir> Map<'hir> {
634
634
self . find_by_hir_id ( hir_id)
635
635
}
636
636
637
- // FIXME(@ljedrz): replace the NodeId variant
637
+ // FIXME(@ljedrz): replace the ` NodeId` variant.
638
638
pub fn find_by_hir_id ( & self , hir_id : HirId ) -> Option < Node < ' hir > > {
639
639
let result = self . find_entry ( hir_id) . and_then ( |entry| {
640
640
if let Node :: Crate = entry. node {
@@ -665,7 +665,7 @@ impl<'hir> Map<'hir> {
665
665
self . hir_to_node_id ( parent_hir_id)
666
666
}
667
667
668
- // FIXME(@ljedrz): replace the NodeId variant
668
+ // FIXME(@ljedrz): replace the ` NodeId` variant.
669
669
pub fn get_parent_node_by_hir_id ( & self , hir_id : HirId ) -> HirId {
670
670
if self . dep_graph . is_fully_enabled ( ) {
671
671
let hir_id_owner = hir_id. owner ;
@@ -721,24 +721,24 @@ impl<'hir> Map<'hir> {
721
721
{
722
722
let mut id = start_id;
723
723
loop {
724
- let parent_node = self . get_parent_node_by_hir_id ( id) ;
725
- if parent_node == CRATE_HIR_ID {
724
+ let parent_id = self . get_parent_node_by_hir_id ( id) ;
725
+ if parent_id == CRATE_HIR_ID {
726
726
return Ok ( CRATE_HIR_ID ) ;
727
727
}
728
- if parent_node == id {
728
+ if parent_id == id {
729
729
return Err ( id) ;
730
730
}
731
731
732
- if let Some ( entry) = self . find_entry ( parent_node ) {
732
+ if let Some ( entry) = self . find_entry ( parent_id ) {
733
733
if let Node :: Crate = entry. node {
734
734
return Err ( id) ;
735
735
}
736
736
if found ( & entry. node ) {
737
- return Ok ( parent_node ) ;
737
+ return Ok ( parent_id ) ;
738
738
} else if bail_early ( & entry. node ) {
739
- return Err ( parent_node ) ;
739
+ return Err ( parent_id ) ;
740
740
}
741
- id = parent_node ;
741
+ id = parent_id ;
742
742
} else {
743
743
return Err ( id) ;
744
744
}
@@ -803,7 +803,7 @@ impl<'hir> Map<'hir> {
803
803
self . hir_to_node_id ( parent_hir_id)
804
804
}
805
805
806
- // FIXME(@ljedrz): replace the NodeId variant
806
+ // FIXME(@ljedrz): replace the ` NodeId` variant.
807
807
pub fn get_parent_item ( & self , hir_id : HirId ) -> HirId {
808
808
match self . walk_parent_nodes ( hir_id, |node| match * node {
809
809
Node :: Item ( _) |
@@ -824,7 +824,7 @@ impl<'hir> Map<'hir> {
824
824
self . get_module_parent_by_hir_id ( hir_id)
825
825
}
826
826
827
- // FIXME(@ljedrz): replace the NodeId variant
827
+ // FIXME(@ljedrz): replace the ` NodeId` variant.
828
828
pub fn get_module_parent_by_hir_id ( & self , id : HirId ) -> DefId {
829
829
self . local_def_id_from_hir_id ( self . get_module_parent_node ( id) )
830
830
}
@@ -861,7 +861,7 @@ impl<'hir> Map<'hir> {
861
861
self . get_parent_did_by_hir_id ( hir_id)
862
862
}
863
863
864
- // FIXME(@ljedrz): replace the NodeId variant
864
+ // FIXME(@ljedrz): replace the ` NodeId` variant.
865
865
pub fn get_parent_did_by_hir_id ( & self , id : HirId ) -> DefId {
866
866
self . local_def_id_from_hir_id ( self . get_parent_item ( id) )
867
867
}
@@ -871,7 +871,7 @@ impl<'hir> Map<'hir> {
871
871
self . get_foreign_abi_by_hir_id ( hir_id)
872
872
}
873
873
874
- // FIXME(@ljedrz): replace the NodeId variant
874
+ // FIXME(@ljedrz): replace the ` NodeId` variant.
875
875
pub fn get_foreign_abi_by_hir_id ( & self , hir_id : HirId ) -> Abi {
876
876
let parent = self . get_parent_item ( hir_id) ;
877
877
if let Some ( entry) = self . find_entry ( parent) {
@@ -890,7 +890,7 @@ impl<'hir> Map<'hir> {
890
890
self . expect_item_by_hir_id ( hir_id)
891
891
}
892
892
893
- // FIXME(@ljedrz): replace the NodeId variant
893
+ // FIXME(@ljedrz): replace the ` NodeId` variant.
894
894
pub fn expect_item_by_hir_id ( & self , id : HirId ) -> & ' hir Item {
895
895
match self . find_by_hir_id ( id) { // read recorded by `find`
896
896
Some ( Node :: Item ( item) ) => item,
@@ -946,7 +946,7 @@ impl<'hir> Map<'hir> {
946
946
self . expect_expr_by_hir_id ( hir_id)
947
947
}
948
948
949
- // FIXME(@ljedrz): replace the NodeId variant
949
+ // FIXME(@ljedrz): replace the ` NodeId` variant.
950
950
pub fn expect_expr_by_hir_id ( & self , id : HirId ) -> & ' hir Expr {
951
951
match self . find_by_hir_id ( id) { // read recorded by find
952
952
Some ( Node :: Expr ( expr) ) => expr,
@@ -960,7 +960,7 @@ impl<'hir> Map<'hir> {
960
960
self . name_by_hir_id ( hir_id)
961
961
}
962
962
963
- // FIXME(@ljedrz): replace the NodeId variant
963
+ // FIXME(@ljedrz): replace the ` NodeId` variant.
964
964
pub fn name_by_hir_id ( & self , id : HirId ) -> Name {
965
965
match self . get_by_hir_id ( id) {
966
966
Node :: Item ( i) => i. ident . name ,
@@ -977,14 +977,14 @@ impl<'hir> Map<'hir> {
977
977
}
978
978
}
979
979
980
- /// Given a node ID, get a list of attributes associated with the AST
981
- /// corresponding to the Node ID
980
+ /// Given a node ID, gets a list of attributes associated with the AST
981
+ /// corresponding to the node-ID.
982
982
pub fn attrs ( & self , id : NodeId ) -> & ' hir [ ast:: Attribute ] {
983
983
let hir_id = self . node_to_hir_id ( id) ;
984
984
self . attrs_by_hir_id ( hir_id)
985
985
}
986
986
987
- // FIXME(@ljedrz): replace the NodeId variant
987
+ // FIXME(@ljedrz): replace the ` NodeId` variant.
988
988
pub fn attrs_by_hir_id ( & self , id : HirId ) -> & ' hir [ ast:: Attribute ] {
989
989
self . read ( id) ; // reveals attributes on the node
990
990
let attrs = match self . find_entry ( id) . map ( |entry| entry. node ) {
@@ -1053,7 +1053,7 @@ impl<'hir> Map<'hir> {
1053
1053
self . span_by_hir_id ( hir_id)
1054
1054
}
1055
1055
1056
- // FIXME(@ljedrz): replace the NodeId variant
1056
+ // FIXME(@ljedrz): replace the ` NodeId` variant.
1057
1057
pub fn span_by_hir_id ( & self , hir_id : HirId ) -> Span {
1058
1058
self . read ( hir_id) ; // reveals span from node
1059
1059
match self . find_entry ( hir_id) . map ( |entry| entry. node ) {
@@ -1101,7 +1101,7 @@ impl<'hir> Map<'hir> {
1101
1101
hir_id_to_string ( self , self . node_to_hir_id ( id) , true )
1102
1102
}
1103
1103
1104
- // FIXME(@ljedrz): replace the NodeId variant
1104
+ // FIXME(@ljedrz): replace the ` NodeId` variant.
1105
1105
pub fn hir_to_string ( & self , id : HirId ) -> String {
1106
1106
hir_id_to_string ( self , id, true )
1107
1107
}
@@ -1110,7 +1110,7 @@ impl<'hir> Map<'hir> {
1110
1110
hir_id_to_string ( self , self . node_to_hir_id ( id) , false )
1111
1111
}
1112
1112
1113
- // FIXME(@ljedrz): replace the NodeId variant
1113
+ // FIXME(@ljedrz): replace the ` NodeId` variant.
1114
1114
pub fn hir_to_user_string ( & self , id : HirId ) -> String {
1115
1115
hir_id_to_string ( self , id, false )
1116
1116
}
@@ -1119,7 +1119,7 @@ impl<'hir> Map<'hir> {
1119
1119
print:: to_string ( self , |s| s. print_node ( self . get ( id) ) )
1120
1120
}
1121
1121
1122
- // FIXME(@ljedrz): replace the NodeId variant
1122
+ // FIXME(@ljedrz): replace the ` NodeId` variant.
1123
1123
pub fn hir_to_pretty_string ( & self , id : HirId ) -> String {
1124
1124
print:: to_string ( self , |s| s. print_node ( self . get_by_hir_id ( id) ) )
1125
1125
}
@@ -1451,8 +1451,9 @@ pub fn provide(providers: &mut Providers<'_>) {
1451
1451
if let Some ( node_id) = tcx. hir ( ) . as_local_node_id ( def_id) {
1452
1452
tcx. hir ( ) . def_kind ( node_id)
1453
1453
} else {
1454
- bug ! ( "Calling local def_kind query provider for upstream DefId: {:?}" ,
1455
- def_id)
1454
+ bug ! ( "calling local def_kind query provider for upstream DefId: {:?}" ,
1455
+ def_id
1456
+ ) ;
1456
1457
}
1457
1458
} ;
1458
1459
}
0 commit comments