Skip to content

Commit 5b9b50e

Browse files
committed
Give HirId to hir::Ty
1 parent 14039a4 commit 5b9b50e

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

src/librustc/hir/lowering.rs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,7 @@ impl<'a> LoweringContext<'a> {
685685
return self.lower_ty(ty);
686686
}
687687
TyKind::Path(ref qself, ref path) => {
688-
let id = self.lower_node_id(t.id).node_id;
688+
let id = self.lower_node_id(t.id);
689689
let qpath = self.lower_qpath(t.id, qself, path, ParamMode::Explicit);
690690
return self.ty_path(id, t.span, qpath);
691691
}
@@ -734,10 +734,12 @@ impl<'a> LoweringContext<'a> {
734734
TyKind::Mac(_) => panic!("TyMac should have been expanded by now."),
735735
};
736736

737+
let LoweredNodeId { node_id, hir_id } = self.lower_node_id(t.id);
737738
P(hir::Ty {
738-
id: self.lower_node_id(t.id).node_id,
739+
id: node_id,
739740
node: kind,
740741
span: t.span,
742+
hir_id,
741743
})
742744
}
743745

@@ -863,7 +865,7 @@ impl<'a> LoweringContext<'a> {
863865
// Otherwise, the base path is an implicit `Self` type path,
864866
// e.g. `Vec` in `Vec::new` or `<I as Iterator>::Item` in
865867
// `<I as Iterator>::Item::default`.
866-
let new_id = self.next_id().node_id;
868+
let new_id = self.next_id();
867869
self.ty_path(new_id, p.span, hir::QPath::Resolved(qself, path))
868870
};
869871

@@ -888,7 +890,7 @@ impl<'a> LoweringContext<'a> {
888890
}
889891

890892
// Wrap the associated extension in another type node.
891-
let new_id = self.next_id().node_id;
893+
let new_id = self.next_id();
892894
ty = self.ty_path(new_id, p.span, qpath);
893895
}
894896

@@ -996,7 +998,8 @@ impl<'a> LoweringContext<'a> {
996998
let &ParenthesizedParameterData { ref inputs, ref output, span } = data;
997999
let inputs = inputs.iter().map(|ty| self.lower_ty(ty)).collect();
9981000
let mk_tup = |this: &mut Self, tys, span| {
999-
P(hir::Ty { node: hir::TyTup(tys), id: this.next_id().node_id, span })
1001+
let LoweredNodeId { node_id, hir_id } = this.next_id();
1002+
P(hir::Ty { node: hir::TyTup(tys), id: node_id, hir_id, span })
10001003
};
10011004

10021005
hir::PathParameters {
@@ -2976,7 +2979,7 @@ impl<'a> LoweringContext<'a> {
29762979
self.expr_block(block, attrs)
29772980
}
29782981

2979-
fn ty_path(&mut self, id: NodeId, span: Span, qpath: hir::QPath) -> P<hir::Ty> {
2982+
fn ty_path(&mut self, id: LoweredNodeId, span: Span, qpath: hir::QPath) -> P<hir::Ty> {
29802983
let mut id = id;
29812984
let node = match qpath {
29822985
hir::QPath::Resolved(None, path) => {
@@ -2986,14 +2989,14 @@ impl<'a> LoweringContext<'a> {
29862989
bound_lifetimes: hir_vec![],
29872990
trait_ref: hir::TraitRef {
29882991
path: path.and_then(|path| path),
2989-
ref_id: id,
2992+
ref_id: id.node_id,
29902993
},
29912994
span,
29922995
};
29932996

29942997
// The original ID is taken by the `PolyTraitRef`,
29952998
// so the `Ty` itself needs a different one.
2996-
id = self.next_id().node_id;
2999+
id = self.next_id();
29973000

29983001
hir::TyTraitObject(hir_vec![principal], self.elided_lifetime(span))
29993002
} else {
@@ -3002,7 +3005,7 @@ impl<'a> LoweringContext<'a> {
30023005
}
30033006
_ => hir::TyPath(qpath)
30043007
};
3005-
P(hir::Ty { id, node, span })
3008+
P(hir::Ty { id: id.node_id, hir_id: id.hir_id, node, span })
30063009
}
30073010

30083011
fn elided_lifetime(&mut self, span: Span) -> hir::Lifetime {

src/librustc/hir/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1354,6 +1354,7 @@ pub struct Ty {
13541354
pub id: NodeId,
13551355
pub node: Ty_,
13561356
pub span: Span,
1357+
pub hir_id: HirId,
13571358
}
13581359

13591360
impl fmt::Debug for Ty {

src/librustc/ich/impls_hir.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@ impl<'gcx> HashStable<StableHashingContext<'gcx>> for hir::Ty {
245245
hcx.while_hashing_hir_bodies(true, |hcx| {
246246
let hir::Ty {
247247
id: _,
248+
hir_id: _,
248249
ref node,
249250
ref span,
250251
} = *self;

0 commit comments

Comments
 (0)