mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-15 01:05:16 +00:00
Give HirId to hir::Ty
This commit is contained in:
parent
14039a42ac
commit
5b9b50e712
@ -685,7 +685,7 @@ impl<'a> LoweringContext<'a> {
|
|||||||
return self.lower_ty(ty);
|
return self.lower_ty(ty);
|
||||||
}
|
}
|
||||||
TyKind::Path(ref qself, ref path) => {
|
TyKind::Path(ref qself, ref path) => {
|
||||||
let id = self.lower_node_id(t.id).node_id;
|
let id = self.lower_node_id(t.id);
|
||||||
let qpath = self.lower_qpath(t.id, qself, path, ParamMode::Explicit);
|
let qpath = self.lower_qpath(t.id, qself, path, ParamMode::Explicit);
|
||||||
return self.ty_path(id, t.span, qpath);
|
return self.ty_path(id, t.span, qpath);
|
||||||
}
|
}
|
||||||
@ -734,10 +734,12 @@ impl<'a> LoweringContext<'a> {
|
|||||||
TyKind::Mac(_) => panic!("TyMac should have been expanded by now."),
|
TyKind::Mac(_) => panic!("TyMac should have been expanded by now."),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let LoweredNodeId { node_id, hir_id } = self.lower_node_id(t.id);
|
||||||
P(hir::Ty {
|
P(hir::Ty {
|
||||||
id: self.lower_node_id(t.id).node_id,
|
id: node_id,
|
||||||
node: kind,
|
node: kind,
|
||||||
span: t.span,
|
span: t.span,
|
||||||
|
hir_id,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -863,7 +865,7 @@ impl<'a> LoweringContext<'a> {
|
|||||||
// Otherwise, the base path is an implicit `Self` type path,
|
// Otherwise, the base path is an implicit `Self` type path,
|
||||||
// e.g. `Vec` in `Vec::new` or `<I as Iterator>::Item` in
|
// e.g. `Vec` in `Vec::new` or `<I as Iterator>::Item` in
|
||||||
// `<I as Iterator>::Item::default`.
|
// `<I as Iterator>::Item::default`.
|
||||||
let new_id = self.next_id().node_id;
|
let new_id = self.next_id();
|
||||||
self.ty_path(new_id, p.span, hir::QPath::Resolved(qself, path))
|
self.ty_path(new_id, p.span, hir::QPath::Resolved(qself, path))
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -888,7 +890,7 @@ impl<'a> LoweringContext<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Wrap the associated extension in another type node.
|
// Wrap the associated extension in another type node.
|
||||||
let new_id = self.next_id().node_id;
|
let new_id = self.next_id();
|
||||||
ty = self.ty_path(new_id, p.span, qpath);
|
ty = self.ty_path(new_id, p.span, qpath);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -996,7 +998,8 @@ impl<'a> LoweringContext<'a> {
|
|||||||
let &ParenthesizedParameterData { ref inputs, ref output, span } = data;
|
let &ParenthesizedParameterData { ref inputs, ref output, span } = data;
|
||||||
let inputs = inputs.iter().map(|ty| self.lower_ty(ty)).collect();
|
let inputs = inputs.iter().map(|ty| self.lower_ty(ty)).collect();
|
||||||
let mk_tup = |this: &mut Self, tys, span| {
|
let mk_tup = |this: &mut Self, tys, span| {
|
||||||
P(hir::Ty { node: hir::TyTup(tys), id: this.next_id().node_id, span })
|
let LoweredNodeId { node_id, hir_id } = this.next_id();
|
||||||
|
P(hir::Ty { node: hir::TyTup(tys), id: node_id, hir_id, span })
|
||||||
};
|
};
|
||||||
|
|
||||||
hir::PathParameters {
|
hir::PathParameters {
|
||||||
@ -2976,7 +2979,7 @@ impl<'a> LoweringContext<'a> {
|
|||||||
self.expr_block(block, attrs)
|
self.expr_block(block, attrs)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn ty_path(&mut self, id: NodeId, span: Span, qpath: hir::QPath) -> P<hir::Ty> {
|
fn ty_path(&mut self, id: LoweredNodeId, span: Span, qpath: hir::QPath) -> P<hir::Ty> {
|
||||||
let mut id = id;
|
let mut id = id;
|
||||||
let node = match qpath {
|
let node = match qpath {
|
||||||
hir::QPath::Resolved(None, path) => {
|
hir::QPath::Resolved(None, path) => {
|
||||||
@ -2986,14 +2989,14 @@ impl<'a> LoweringContext<'a> {
|
|||||||
bound_lifetimes: hir_vec![],
|
bound_lifetimes: hir_vec![],
|
||||||
trait_ref: hir::TraitRef {
|
trait_ref: hir::TraitRef {
|
||||||
path: path.and_then(|path| path),
|
path: path.and_then(|path| path),
|
||||||
ref_id: id,
|
ref_id: id.node_id,
|
||||||
},
|
},
|
||||||
span,
|
span,
|
||||||
};
|
};
|
||||||
|
|
||||||
// The original ID is taken by the `PolyTraitRef`,
|
// The original ID is taken by the `PolyTraitRef`,
|
||||||
// so the `Ty` itself needs a different one.
|
// so the `Ty` itself needs a different one.
|
||||||
id = self.next_id().node_id;
|
id = self.next_id();
|
||||||
|
|
||||||
hir::TyTraitObject(hir_vec![principal], self.elided_lifetime(span))
|
hir::TyTraitObject(hir_vec![principal], self.elided_lifetime(span))
|
||||||
} else {
|
} else {
|
||||||
@ -3002,7 +3005,7 @@ impl<'a> LoweringContext<'a> {
|
|||||||
}
|
}
|
||||||
_ => hir::TyPath(qpath)
|
_ => hir::TyPath(qpath)
|
||||||
};
|
};
|
||||||
P(hir::Ty { id, node, span })
|
P(hir::Ty { id: id.node_id, hir_id: id.hir_id, node, span })
|
||||||
}
|
}
|
||||||
|
|
||||||
fn elided_lifetime(&mut self, span: Span) -> hir::Lifetime {
|
fn elided_lifetime(&mut self, span: Span) -> hir::Lifetime {
|
||||||
|
@ -1354,6 +1354,7 @@ pub struct Ty {
|
|||||||
pub id: NodeId,
|
pub id: NodeId,
|
||||||
pub node: Ty_,
|
pub node: Ty_,
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
|
pub hir_id: HirId,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Debug for Ty {
|
impl fmt::Debug for Ty {
|
||||||
|
@ -245,6 +245,7 @@ impl<'gcx> HashStable<StableHashingContext<'gcx>> for hir::Ty {
|
|||||||
hcx.while_hashing_hir_bodies(true, |hcx| {
|
hcx.while_hashing_hir_bodies(true, |hcx| {
|
||||||
let hir::Ty {
|
let hir::Ty {
|
||||||
id: _,
|
id: _,
|
||||||
|
hir_id: _,
|
||||||
ref node,
|
ref node,
|
||||||
ref span,
|
ref span,
|
||||||
} = *self;
|
} = *self;
|
||||||
|
Loading…
Reference in New Issue
Block a user