@@ -146,6 +146,7 @@ pub const DUMMY_ITEM_LOCAL_ID: ItemLocalId = ItemLocalId::MAX;
146
146
#[ derive( Clone , RustcEncodable , RustcDecodable , Copy ) ]
147
147
pub struct Lifetime {
148
148
pub id : NodeId ,
149
+ pub hir_id : HirId ,
149
150
pub span : Span ,
150
151
151
152
/// Either "'a", referring to a named lifetime definition,
@@ -321,6 +322,7 @@ pub struct PathSegment {
321
322
// affected. (In general, we don't bother to get the defs for synthesized
322
323
// segments, only for segments which have come from the AST).
323
324
pub id : Option < NodeId > ,
325
+ pub hir_id : Option < HirId > ,
324
326
pub def : Option < Def > ,
325
327
326
328
/// Type/lifetime parameters attached to this path. They come in
@@ -343,6 +345,7 @@ impl PathSegment {
343
345
PathSegment {
344
346
ident,
345
347
id : None ,
348
+ hir_id : None ,
346
349
def : None ,
347
350
infer_types : true ,
348
351
args : None ,
@@ -352,13 +355,15 @@ impl PathSegment {
352
355
pub fn new (
353
356
ident : Ident ,
354
357
id : Option < NodeId > ,
358
+ hir_id : Option < HirId > ,
355
359
def : Option < Def > ,
356
360
args : GenericArgs ,
357
361
infer_types : bool ,
358
362
) -> Self {
359
363
PathSegment {
360
364
ident,
361
365
id,
366
+ hir_id,
362
367
def,
363
368
infer_types,
364
369
args : if args. is_empty ( ) {
@@ -528,6 +533,7 @@ pub enum GenericParamKind {
528
533
#[ derive( Clone , RustcEncodable , RustcDecodable , Debug ) ]
529
534
pub struct GenericParam {
530
535
pub id : NodeId ,
536
+ pub hir_id : HirId ,
531
537
pub name : ParamName ,
532
538
pub attrs : HirVec < Attribute > ,
533
539
pub bounds : GenericBounds ,
@@ -558,6 +564,7 @@ impl Generics {
558
564
params : HirVec :: new ( ) ,
559
565
where_clause : WhereClause {
560
566
id : DUMMY_NODE_ID ,
567
+ hir_id : DUMMY_HIR_ID ,
561
568
predicates : HirVec :: new ( ) ,
562
569
} ,
563
570
span : DUMMY_SP ,
@@ -601,6 +608,7 @@ pub enum SyntheticTyParamKind {
601
608
#[ derive( Clone , RustcEncodable , RustcDecodable , Debug ) ]
602
609
pub struct WhereClause {
603
610
pub id : NodeId ,
611
+ pub hir_id : HirId ,
604
612
pub predicates : HirVec < WherePredicate > ,
605
613
}
606
614
@@ -661,6 +669,7 @@ pub struct WhereRegionPredicate {
661
669
#[ derive( Clone , RustcEncodable , RustcDecodable , Debug ) ]
662
670
pub struct WhereEqPredicate {
663
671
pub id : NodeId ,
672
+ pub hir_id : HirId ,
664
673
pub span : Span ,
665
674
pub lhs_ty : P < Ty > ,
666
675
pub rhs_ty : P < Ty > ,
@@ -789,6 +798,7 @@ pub struct MacroDef {
789
798
pub vis : Visibility ,
790
799
pub attrs : HirVec < Attribute > ,
791
800
pub id : NodeId ,
801
+ pub hir_id : HirId ,
792
802
pub span : Span ,
793
803
pub body : TokenStream ,
794
804
pub legacy : bool ,
@@ -878,6 +888,7 @@ impl Pat {
878
888
#[ derive( Clone , RustcEncodable , RustcDecodable , Debug ) ]
879
889
pub struct FieldPat {
880
890
pub id : NodeId ,
891
+ pub hir_id : HirId ,
881
892
/// The identifier for the field
882
893
pub ident : Ident ,
883
894
/// The pattern the field is destructured to
@@ -924,7 +935,7 @@ pub enum PatKind {
924
935
/// The `NodeId` is the canonical ID for the variable being bound,
925
936
/// e.g., in `Ok(x) | Err(x)`, both `x` use the same canonical ID,
926
937
/// which is the pattern ID of the first `x`.
927
- Binding ( BindingAnnotation , NodeId , Ident , Option < P < Pat > > ) ,
938
+ Binding ( BindingAnnotation , NodeId , HirId , Ident , Option < P < Pat > > ) ,
928
939
929
940
/// A struct or struct variant pattern, e.g., `Variant {x, y, ..}`.
930
941
/// The `bool` is `true` in the presence of a `..`.
@@ -1137,6 +1148,7 @@ impl UnOp {
1137
1148
#[ derive( Clone , RustcEncodable , RustcDecodable ) ]
1138
1149
pub struct Stmt {
1139
1150
pub id : NodeId ,
1151
+ pub hir_id : HirId ,
1140
1152
pub node : StmtKind ,
1141
1153
pub span : Span ,
1142
1154
}
@@ -1204,6 +1216,7 @@ pub enum Guard {
1204
1216
#[ derive( Clone , RustcEncodable , RustcDecodable , Debug ) ]
1205
1217
pub struct Field {
1206
1218
pub id : NodeId ,
1219
+ pub hir_id : HirId ,
1207
1220
pub ident : Ident ,
1208
1221
pub expr : P < Expr > ,
1209
1222
pub span : Span ,
@@ -1711,6 +1724,7 @@ pub enum ImplItemKind {
1711
1724
#[ derive( Clone , RustcEncodable , RustcDecodable , Debug ) ]
1712
1725
pub struct TypeBinding {
1713
1726
pub id : NodeId ,
1727
+ pub hir_id : HirId ,
1714
1728
pub ident : Ident ,
1715
1729
pub ty : P < Ty > ,
1716
1730
pub span : Span ,
@@ -2106,6 +2120,7 @@ pub struct StructField {
2106
2120
pub ident : Ident ,
2107
2121
pub vis : Visibility ,
2108
2122
pub id : NodeId ,
2123
+ pub hir_id : HirId ,
2109
2124
pub ty : P < Ty > ,
2110
2125
pub attrs : HirVec < Attribute > ,
2111
2126
}
@@ -2131,21 +2146,30 @@ impl StructField {
2131
2146
/// Id of the whole struct lives in `Item`.
2132
2147
#[ derive( Clone , RustcEncodable , RustcDecodable , Debug ) ]
2133
2148
pub enum VariantData {
2134
- Struct ( HirVec < StructField > , NodeId ) ,
2135
- Tuple ( HirVec < StructField > , NodeId ) ,
2136
- Unit ( NodeId ) ,
2149
+ Struct ( HirVec < StructField > , NodeId , HirId ) ,
2150
+ Tuple ( HirVec < StructField > , NodeId , HirId ) ,
2151
+ Unit ( NodeId , HirId ) ,
2137
2152
}
2138
2153
2139
2154
impl VariantData {
2140
2155
pub fn fields ( & self ) -> & [ StructField ] {
2141
2156
match * self {
2142
- VariantData :: Struct ( ref fields, _ ) | VariantData :: Tuple ( ref fields, _ ) => fields,
2157
+ VariantData :: Struct ( ref fields, .. ) | VariantData :: Tuple ( ref fields, .. ) => fields,
2143
2158
_ => & [ ] ,
2144
2159
}
2145
2160
}
2146
2161
pub fn id ( & self ) -> NodeId {
2147
2162
match * self {
2148
- VariantData :: Struct ( _, id) | VariantData :: Tuple ( _, id) | VariantData :: Unit ( id) => id,
2163
+ VariantData :: Struct ( _, id, ..)
2164
+ | VariantData :: Tuple ( _, id, ..)
2165
+ | VariantData :: Unit ( id, ..) => id,
2166
+ }
2167
+ }
2168
+ pub fn hir_id ( & self ) -> HirId {
2169
+ match * self {
2170
+ VariantData :: Struct ( _, _, hir_id)
2171
+ | VariantData :: Tuple ( _, _, hir_id)
2172
+ | VariantData :: Unit ( _, hir_id) => hir_id,
2149
2173
}
2150
2174
}
2151
2175
pub fn is_struct ( & self ) -> bool {
@@ -2343,6 +2367,7 @@ pub struct ForeignItem {
2343
2367
pub attrs : HirVec < Attribute > ,
2344
2368
pub node : ForeignItemKind ,
2345
2369
pub id : NodeId ,
2370
+ pub hir_id : HirId ,
2346
2371
pub span : Span ,
2347
2372
pub vis : Visibility ,
2348
2373
}
0 commit comments