@@ -146,6 +146,7 @@ pub const DUMMY_ITEM_LOCAL_ID: ItemLocalId = ItemLocalId::MAX;
146146#[ derive( Clone , RustcEncodable , RustcDecodable , Copy ) ]
147147pub struct Lifetime {
148148 pub id : NodeId ,
149+ pub hir_id : HirId ,
149150 pub span : Span ,
150151
151152 /// Either "'a", referring to a named lifetime definition,
@@ -321,6 +322,7 @@ pub struct PathSegment {
321322 // affected. (In general, we don't bother to get the defs for synthesized
322323 // segments, only for segments which have come from the AST).
323324 pub id : Option < NodeId > ,
325+ pub hir_id : Option < HirId > ,
324326 pub def : Option < Def > ,
325327
326328 /// Type/lifetime parameters attached to this path. They come in
@@ -343,6 +345,7 @@ impl PathSegment {
343345 PathSegment {
344346 ident,
345347 id : None ,
348+ hir_id : None ,
346349 def : None ,
347350 infer_types : true ,
348351 args : None ,
@@ -352,13 +355,15 @@ impl PathSegment {
352355 pub fn new (
353356 ident : Ident ,
354357 id : Option < NodeId > ,
358+ hir_id : Option < HirId > ,
355359 def : Option < Def > ,
356360 args : GenericArgs ,
357361 infer_types : bool ,
358362 ) -> Self {
359363 PathSegment {
360364 ident,
361365 id,
366+ hir_id,
362367 def,
363368 infer_types,
364369 args : if args. is_empty ( ) {
@@ -528,6 +533,7 @@ pub enum GenericParamKind {
528533#[ derive( Clone , RustcEncodable , RustcDecodable , Debug ) ]
529534pub struct GenericParam {
530535 pub id : NodeId ,
536+ pub hir_id : HirId ,
531537 pub name : ParamName ,
532538 pub attrs : HirVec < Attribute > ,
533539 pub bounds : GenericBounds ,
@@ -558,6 +564,7 @@ impl Generics {
558564 params : HirVec :: new ( ) ,
559565 where_clause : WhereClause {
560566 id : DUMMY_NODE_ID ,
567+ hir_id : DUMMY_HIR_ID ,
561568 predicates : HirVec :: new ( ) ,
562569 } ,
563570 span : DUMMY_SP ,
@@ -601,6 +608,7 @@ pub enum SyntheticTyParamKind {
601608#[ derive( Clone , RustcEncodable , RustcDecodable , Debug ) ]
602609pub struct WhereClause {
603610 pub id : NodeId ,
611+ pub hir_id : HirId ,
604612 pub predicates : HirVec < WherePredicate > ,
605613}
606614
@@ -661,6 +669,7 @@ pub struct WhereRegionPredicate {
661669#[ derive( Clone , RustcEncodable , RustcDecodable , Debug ) ]
662670pub struct WhereEqPredicate {
663671 pub id : NodeId ,
672+ pub hir_id : HirId ,
664673 pub span : Span ,
665674 pub lhs_ty : P < Ty > ,
666675 pub rhs_ty : P < Ty > ,
@@ -789,6 +798,7 @@ pub struct MacroDef {
789798 pub vis : Visibility ,
790799 pub attrs : HirVec < Attribute > ,
791800 pub id : NodeId ,
801+ pub hir_id : HirId ,
792802 pub span : Span ,
793803 pub body : TokenStream ,
794804 pub legacy : bool ,
@@ -878,6 +888,7 @@ impl Pat {
878888#[ derive( Clone , RustcEncodable , RustcDecodable , Debug ) ]
879889pub struct FieldPat {
880890 pub id : NodeId ,
891+ pub hir_id : HirId ,
881892 /// The identifier for the field
882893 pub ident : Ident ,
883894 /// The pattern the field is destructured to
@@ -924,7 +935,7 @@ pub enum PatKind {
924935 /// The `NodeId` is the canonical ID for the variable being bound,
925936 /// e.g., in `Ok(x) | Err(x)`, both `x` use the same canonical ID,
926937 /// 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 > > ) ,
928939
929940 /// A struct or struct variant pattern, e.g., `Variant {x, y, ..}`.
930941 /// The `bool` is `true` in the presence of a `..`.
@@ -1137,6 +1148,7 @@ impl UnOp {
11371148#[ derive( Clone , RustcEncodable , RustcDecodable ) ]
11381149pub struct Stmt {
11391150 pub id : NodeId ,
1151+ pub hir_id : HirId ,
11401152 pub node : StmtKind ,
11411153 pub span : Span ,
11421154}
@@ -1204,6 +1216,7 @@ pub enum Guard {
12041216#[ derive( Clone , RustcEncodable , RustcDecodable , Debug ) ]
12051217pub struct Field {
12061218 pub id : NodeId ,
1219+ pub hir_id : HirId ,
12071220 pub ident : Ident ,
12081221 pub expr : P < Expr > ,
12091222 pub span : Span ,
@@ -1711,6 +1724,7 @@ pub enum ImplItemKind {
17111724#[ derive( Clone , RustcEncodable , RustcDecodable , Debug ) ]
17121725pub struct TypeBinding {
17131726 pub id : NodeId ,
1727+ pub hir_id : HirId ,
17141728 pub ident : Ident ,
17151729 pub ty : P < Ty > ,
17161730 pub span : Span ,
@@ -2106,6 +2120,7 @@ pub struct StructField {
21062120 pub ident : Ident ,
21072121 pub vis : Visibility ,
21082122 pub id : NodeId ,
2123+ pub hir_id : HirId ,
21092124 pub ty : P < Ty > ,
21102125 pub attrs : HirVec < Attribute > ,
21112126}
@@ -2131,21 +2146,30 @@ impl StructField {
21312146/// Id of the whole struct lives in `Item`.
21322147#[ derive( Clone , RustcEncodable , RustcDecodable , Debug ) ]
21332148pub 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 ) ,
21372152}
21382153
21392154impl VariantData {
21402155 pub fn fields ( & self ) -> & [ StructField ] {
21412156 match * self {
2142- VariantData :: Struct ( ref fields, _ ) | VariantData :: Tuple ( ref fields, _ ) => fields,
2157+ VariantData :: Struct ( ref fields, .. ) | VariantData :: Tuple ( ref fields, .. ) => fields,
21432158 _ => & [ ] ,
21442159 }
21452160 }
21462161 pub fn id ( & self ) -> NodeId {
21472162 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,
21492173 }
21502174 }
21512175 pub fn is_struct ( & self ) -> bool {
@@ -2343,6 +2367,7 @@ pub struct ForeignItem {
23432367 pub attrs : HirVec < Attribute > ,
23442368 pub node : ForeignItemKind ,
23452369 pub id : NodeId ,
2370+ pub hir_id : HirId ,
23462371 pub span : Span ,
23472372 pub vis : Visibility ,
23482373}
0 commit comments