@@ -50,7 +50,7 @@ impl<'hir> Entry<'hir> {
50
50
fn fn_decl ( & self ) -> Option < & ' hir FnDecl > {
51
51
match self . node {
52
52
Node :: Item ( ref item) => {
53
- match item. node {
53
+ match item. kind {
54
54
ItemKind :: Fn ( ref fn_decl, _, _, _) => Some ( fn_decl) ,
55
55
_ => None ,
56
56
}
@@ -84,7 +84,7 @@ impl<'hir> Entry<'hir> {
84
84
fn associated_body ( self ) -> Option < BodyId > {
85
85
match self . node {
86
86
Node :: Item ( item) => {
87
- match item. node {
87
+ match item. kind {
88
88
ItemKind :: Const ( _, body) |
89
89
ItemKind :: Static ( .., body) |
90
90
ItemKind :: Fn ( _, _, _, body) => Some ( body) ,
@@ -293,7 +293,7 @@ impl<'hir> Map<'hir> {
293
293
294
294
Some ( match node {
295
295
Node :: Item ( item) => {
296
- match item. node {
296
+ match item. kind {
297
297
ItemKind :: Static ( ..) => DefKind :: Static ,
298
298
ItemKind :: Const ( ..) => DefKind :: Const ,
299
299
ItemKind :: Fn ( ..) => DefKind :: Fn ,
@@ -453,19 +453,19 @@ impl<'hir> Map<'hir> {
453
453
454
454
pub fn body_owner_kind ( & self , id : HirId ) -> BodyOwnerKind {
455
455
match self . get ( id) {
456
- Node :: Item ( & Item { node : ItemKind :: Const ( ..) , .. } ) |
456
+ Node :: Item ( & Item { kind : ItemKind :: Const ( ..) , .. } ) |
457
457
Node :: TraitItem ( & TraitItem { kind : TraitItemKind :: Const ( ..) , .. } ) |
458
458
Node :: ImplItem ( & ImplItem { kind : ImplItemKind :: Const ( ..) , .. } ) |
459
459
Node :: AnonConst ( _) => {
460
460
BodyOwnerKind :: Const
461
461
}
462
462
Node :: Ctor ( ..) |
463
- Node :: Item ( & Item { node : ItemKind :: Fn ( ..) , .. } ) |
463
+ Node :: Item ( & Item { kind : ItemKind :: Fn ( ..) , .. } ) |
464
464
Node :: TraitItem ( & TraitItem { kind : TraitItemKind :: Method ( ..) , .. } ) |
465
465
Node :: ImplItem ( & ImplItem { kind : ImplItemKind :: Method ( ..) , .. } ) => {
466
466
BodyOwnerKind :: Fn
467
467
}
468
- Node :: Item ( & Item { node : ItemKind :: Static ( _, m, _) , .. } ) => {
468
+ Node :: Item ( & Item { kind : ItemKind :: Static ( _, m, _) , .. } ) => {
469
469
BodyOwnerKind :: Static ( m)
470
470
}
471
471
Node :: Expr ( & Expr { kind : ExprKind :: Closure ( ..) , .. } ) => {
@@ -477,17 +477,17 @@ impl<'hir> Map<'hir> {
477
477
478
478
pub fn ty_param_owner ( & self , id : HirId ) -> HirId {
479
479
match self . get ( id) {
480
- Node :: Item ( & Item { node : ItemKind :: Trait ( ..) , .. } ) |
481
- Node :: Item ( & Item { node : ItemKind :: TraitAlias ( ..) , .. } ) => id,
480
+ Node :: Item ( & Item { kind : ItemKind :: Trait ( ..) , .. } ) |
481
+ Node :: Item ( & Item { kind : ItemKind :: TraitAlias ( ..) , .. } ) => id,
482
482
Node :: GenericParam ( _) => self . get_parent_node ( id) ,
483
483
_ => bug ! ( "ty_param_owner: {} not a type parameter" , self . node_to_string( id) )
484
484
}
485
485
}
486
486
487
487
pub fn ty_param_name ( & self , id : HirId ) -> Name {
488
488
match self . get ( id) {
489
- Node :: Item ( & Item { node : ItemKind :: Trait ( ..) , .. } ) |
490
- Node :: Item ( & Item { node : ItemKind :: TraitAlias ( ..) , .. } ) => kw:: SelfUpper ,
489
+ Node :: Item ( & Item { kind : ItemKind :: Trait ( ..) , .. } ) |
490
+ Node :: Item ( & Item { kind : ItemKind :: TraitAlias ( ..) , .. } ) => kw:: SelfUpper ,
491
491
Node :: GenericParam ( param) => param. name . ident ( ) . name ,
492
492
_ => bug ! ( "ty_param_name: {} not a type parameter" , self . node_to_string( id) ) ,
493
493
}
@@ -517,7 +517,7 @@ impl<'hir> Map<'hir> {
517
517
match self . find_entry ( hir_id) . unwrap ( ) . node {
518
518
Node :: Item ( & Item {
519
519
span,
520
- node : ItemKind :: Mod ( ref m) ,
520
+ kind : ItemKind :: Mod ( ref m) ,
521
521
..
522
522
} ) => ( m, span, hir_id) ,
523
523
Node :: Crate => ( & self . forest . krate . module , self . forest . krate . span , hir_id) ,
@@ -568,7 +568,7 @@ impl<'hir> Map<'hir> {
568
568
Node :: ImplItem ( ref impl_item) => Some ( & impl_item. generics ) ,
569
569
Node :: TraitItem ( ref trait_item) => Some ( & trait_item. generics ) ,
570
570
Node :: Item ( ref item) => {
571
- match item. node {
571
+ match item. kind {
572
572
ItemKind :: Fn ( _, _, ref generics, _) |
573
573
ItemKind :: TyAlias ( _, ref generics) |
574
574
ItemKind :: Enum ( _, ref generics) |
@@ -649,7 +649,7 @@ impl<'hir> Map<'hir> {
649
649
let parent_id = self . get_parent_item ( hir_id) ;
650
650
match self . get ( parent_id) {
651
651
Node :: Item ( & Item {
652
- node : ItemKind :: Const ( ..) ,
652
+ kind : ItemKind :: Const ( ..) ,
653
653
..
654
654
} )
655
655
| Node :: TraitItem ( & TraitItem {
@@ -662,11 +662,11 @@ impl<'hir> Map<'hir> {
662
662
} )
663
663
| Node :: AnonConst ( _)
664
664
| Node :: Item ( & Item {
665
- node : ItemKind :: Static ( ..) ,
665
+ kind : ItemKind :: Static ( ..) ,
666
666
..
667
667
} ) => true ,
668
668
Node :: Item ( & Item {
669
- node : ItemKind :: Fn ( _, header, ..) ,
669
+ kind : ItemKind :: Fn ( _, header, ..) ,
670
670
..
671
671
} ) => header. constness == Constness :: Const ,
672
672
_ => false ,
@@ -676,7 +676,7 @@ impl<'hir> Map<'hir> {
676
676
/// Wether `hir_id` corresponds to a `mod` or a crate.
677
677
pub fn is_hir_id_module ( & self , hir_id : HirId ) -> bool {
678
678
match self . lookup ( hir_id) {
679
- Some ( Entry { node : Node :: Item ( Item { node : ItemKind :: Mod ( _) , .. } ) , .. } ) |
679
+ Some ( Entry { node : Node :: Item ( Item { kind : ItemKind :: Mod ( _) , .. } ) , .. } ) |
680
680
Some ( Entry { node : Node :: Crate , .. } ) => true ,
681
681
_ => false ,
682
682
}
@@ -796,7 +796,7 @@ impl<'hir> Map<'hir> {
796
796
/// module parent is in this map.
797
797
pub fn get_module_parent_node ( & self , hir_id : HirId ) -> HirId {
798
798
match self . walk_parent_nodes ( hir_id, |node| match * node {
799
- Node :: Item ( & Item { node : ItemKind :: Mod ( _) , .. } ) => true ,
799
+ Node :: Item ( & Item { kind : ItemKind :: Mod ( _) , .. } ) => true ,
800
800
_ => false ,
801
801
} , |_| false ) {
802
802
Ok ( id) => id,
@@ -808,7 +808,7 @@ impl<'hir> Map<'hir> {
808
808
pub fn get_enclosing_scope ( & self , hir_id : HirId ) -> Option < HirId > {
809
809
self . walk_parent_nodes ( hir_id, |node| match * node {
810
810
Node :: Item ( i) => {
811
- match i. node {
811
+ match i. kind {
812
812
ItemKind :: Fn ( ..)
813
813
| ItemKind :: Mod ( ..)
814
814
| ItemKind :: Enum ( ..)
@@ -852,7 +852,7 @@ impl<'hir> Map<'hir> {
852
852
}
853
853
match self . get ( scope) {
854
854
Node :: Item ( i) => {
855
- match i. node {
855
+ match i. kind {
856
856
ItemKind :: OpaqueTy ( OpaqueTy { impl_trait_fn : None , .. } ) => { }
857
857
_ => break ,
858
858
}
@@ -872,7 +872,7 @@ impl<'hir> Map<'hir> {
872
872
let parent = self . get_parent_item ( hir_id) ;
873
873
if let Some ( entry) = self . find_entry ( parent) {
874
874
if let Entry {
875
- node : Node :: Item ( Item { node : ItemKind :: ForeignMod ( ref nm) , .. } ) , .. } = entry
875
+ node : Node :: Item ( Item { kind : ItemKind :: ForeignMod ( ref nm) , .. } ) , .. } = entry
876
876
{
877
877
self . read ( hir_id) ; // reveals some of the content of a node
878
878
return nm. abi ;
@@ -905,7 +905,7 @@ impl<'hir> Map<'hir> {
905
905
pub fn expect_variant_data ( & self , id : HirId ) -> & ' hir VariantData {
906
906
match self . find ( id) {
907
907
Some ( Node :: Item ( i) ) => {
908
- match i. node {
908
+ match i. kind {
909
909
ItemKind :: Struct ( ref struct_def, _) |
910
910
ItemKind :: Union ( ref struct_def, _) => struct_def,
911
911
_ => bug ! ( "struct ID bound to non-struct {}" , self . node_to_string( id) )
@@ -1123,7 +1123,7 @@ impl<'a> NodesMatchingSuffix<'a> {
1123
1123
}
1124
1124
1125
1125
fn item_is_mod ( item : & Item ) -> bool {
1126
- match item. node {
1126
+ match item. kind {
1127
1127
ItemKind :: Mod ( _) => true ,
1128
1128
_ => false ,
1129
1129
}
@@ -1286,7 +1286,7 @@ fn hir_id_to_string(map: &Map<'_>, id: HirId, include_id: bool) -> String {
1286
1286
1287
1287
match map. find ( id) {
1288
1288
Some ( Node :: Item ( item) ) => {
1289
- let item_str = match item. node {
1289
+ let item_str = match item. kind {
1290
1290
ItemKind :: ExternCrate ( ..) => "extern crate" ,
1291
1291
ItemKind :: Use ( ..) => "use" ,
1292
1292
ItemKind :: Static ( ..) => "static" ,
0 commit comments