hir: remove NodeId from VariantData
This commit is contained in:
parent
50b8bc8c8c
commit
fb22315f08
@ -2674,7 +2674,7 @@ impl<'a> LoweringContext<'a> {
|
||||
fn lower_variant_data(&mut self, vdata: &VariantData) -> hir::VariantData {
|
||||
match *vdata {
|
||||
VariantData::Struct(ref fields, id) => {
|
||||
let LoweredNodeId { node_id, hir_id } = self.lower_node_id(id);
|
||||
let LoweredNodeId { node_id: _, hir_id } = self.lower_node_id(id);
|
||||
|
||||
hir::VariantData::Struct(
|
||||
fields
|
||||
@ -2682,12 +2682,11 @@ impl<'a> LoweringContext<'a> {
|
||||
.enumerate()
|
||||
.map(|f| self.lower_struct_field(f))
|
||||
.collect(),
|
||||
node_id,
|
||||
hir_id,
|
||||
)
|
||||
},
|
||||
VariantData::Tuple(ref fields, id) => {
|
||||
let LoweredNodeId { node_id, hir_id } = self.lower_node_id(id);
|
||||
let LoweredNodeId { node_id: _, hir_id } = self.lower_node_id(id);
|
||||
|
||||
hir::VariantData::Tuple(
|
||||
fields
|
||||
@ -2695,14 +2694,13 @@ impl<'a> LoweringContext<'a> {
|
||||
.enumerate()
|
||||
.map(|f| self.lower_struct_field(f))
|
||||
.collect(),
|
||||
node_id,
|
||||
hir_id,
|
||||
)
|
||||
},
|
||||
VariantData::Unit(id) => {
|
||||
let LoweredNodeId { node_id, hir_id } = self.lower_node_id(id);
|
||||
let LoweredNodeId { node_id: _, hir_id } = self.lower_node_id(id);
|
||||
|
||||
hir::VariantData::Unit(node_id, hir_id)
|
||||
hir::VariantData::Unit(hir_id)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -366,11 +366,11 @@ impl<'hir> Map<'hir> {
|
||||
}
|
||||
}
|
||||
Node::Variant(variant) => {
|
||||
let def_id = self.local_def_id(variant.node.data.id());
|
||||
let def_id = self.local_def_id_from_hir_id(variant.node.data.hir_id());
|
||||
Some(Def::Variant(def_id))
|
||||
}
|
||||
Node::StructCtor(variant) => {
|
||||
let def_id = self.local_def_id(variant.id());
|
||||
let def_id = self.local_def_id_from_hir_id(variant.hir_id());
|
||||
Some(Def::StructCtor(def_id, def::CtorKind::from_hir(variant)))
|
||||
}
|
||||
Node::AnonConst(_) |
|
||||
|
@ -2156,9 +2156,9 @@ impl StructField {
|
||||
/// Id of the whole struct lives in `Item`.
|
||||
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
|
||||
pub enum VariantData {
|
||||
Struct(HirVec<StructField>, NodeId, HirId),
|
||||
Tuple(HirVec<StructField>, NodeId, HirId),
|
||||
Unit(NodeId, HirId),
|
||||
Struct(HirVec<StructField>, HirId),
|
||||
Tuple(HirVec<StructField>, HirId),
|
||||
Unit(HirId),
|
||||
}
|
||||
|
||||
impl VariantData {
|
||||
@ -2168,18 +2168,11 @@ impl VariantData {
|
||||
_ => &[],
|
||||
}
|
||||
}
|
||||
pub fn id(&self) -> NodeId {
|
||||
match *self {
|
||||
VariantData::Struct(_, id, ..)
|
||||
| VariantData::Tuple(_, id, ..)
|
||||
| VariantData::Unit(id, ..) => id,
|
||||
}
|
||||
}
|
||||
pub fn hir_id(&self) -> HirId {
|
||||
match *self {
|
||||
VariantData::Struct(_, _, hir_id)
|
||||
| VariantData::Tuple(_, _, hir_id)
|
||||
| VariantData::Unit(_, hir_id) => hir_id,
|
||||
VariantData::Struct(_, hir_id)
|
||||
| VariantData::Tuple(_, hir_id)
|
||||
| VariantData::Unit(hir_id) => hir_id,
|
||||
}
|
||||
}
|
||||
pub fn is_struct(&self) -> bool {
|
||||
|
@ -842,9 +842,9 @@ impl_stable_hash_for!(struct hir::StructField {
|
||||
});
|
||||
|
||||
impl_stable_hash_for!(enum hir::VariantData {
|
||||
Struct(fields, id, hir_id),
|
||||
Tuple(fields, id, hir_id),
|
||||
Unit(id, hir_id)
|
||||
Struct(fields, hir_id),
|
||||
Tuple(fields, hir_id),
|
||||
Unit(hir_id)
|
||||
});
|
||||
|
||||
impl<'a> HashStable<StableHashingContext<'a>> for hir::Item {
|
||||
|
@ -1069,7 +1069,7 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> {
|
||||
// for methods, write all the stuff get_trait_method
|
||||
// needs to know
|
||||
let struct_ctor = if !struct_def.is_struct() {
|
||||
Some(tcx.hir().local_def_id(struct_def.id()).index)
|
||||
Some(tcx.hir().local_def_id_from_hir_id(struct_def.hir_id()).index)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
@ -1772,7 +1772,7 @@ impl<'a, 'b, 'tcx> IndexBuilder<'a, 'b, 'tcx> {
|
||||
|
||||
// If the struct has a constructor, encode it.
|
||||
if !struct_def.is_struct() {
|
||||
let ctor_def_id = self.tcx.hir().local_def_id(struct_def.id());
|
||||
let ctor_def_id = self.tcx.hir().local_def_id_from_hir_id(struct_def.hir_id());
|
||||
self.record(ctor_def_id,
|
||||
IsolatedEncoder::encode_struct_ctor,
|
||||
(def_id, ctor_def_id));
|
||||
|
@ -229,7 +229,7 @@ fn create_constructor_shim<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
-> Mir<'tcx>
|
||||
{
|
||||
let span = tcx.hir().span(ctor_id);
|
||||
if let hir::VariantData::Tuple(ref fields, ctor_id, _) = *v {
|
||||
if let hir::VariantData::Tuple(ref fields, ctor_id) = *v {
|
||||
tcx.infer_ctxt().enter(|infcx| {
|
||||
let mut mir = shim::build_adt_ctor(&infcx, ctor_id, fields, span);
|
||||
|
||||
@ -245,7 +245,7 @@ fn create_constructor_shim<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
};
|
||||
|
||||
mir_util::dump_mir(tcx, None, "mir_map", &0,
|
||||
MirSource::item(tcx.hir().local_def_id(ctor_id)),
|
||||
MirSource::item(tcx.hir().local_def_id_from_hir_id(ctor_id)),
|
||||
&mir, |_, _| Ok(()) );
|
||||
|
||||
mir
|
||||
|
@ -10,7 +10,6 @@ use rustc::ty::query::Providers;
|
||||
use rustc_data_structures::indexed_vec::{IndexVec, Idx};
|
||||
|
||||
use rustc_target::spec::abi::Abi;
|
||||
use syntax::ast;
|
||||
use syntax_pos::Span;
|
||||
|
||||
use std::fmt;
|
||||
@ -855,14 +854,14 @@ fn build_call_shim<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
}
|
||||
|
||||
pub fn build_adt_ctor<'a, 'gcx, 'tcx>(infcx: &infer::InferCtxt<'a, 'gcx, 'tcx>,
|
||||
ctor_id: ast::NodeId,
|
||||
ctor_id: hir::HirId,
|
||||
fields: &[hir::StructField],
|
||||
span: Span)
|
||||
-> Mir<'tcx>
|
||||
{
|
||||
let tcx = infcx.tcx;
|
||||
let gcx = tcx.global_tcx();
|
||||
let def_id = tcx.hir().local_def_id(ctor_id);
|
||||
let def_id = tcx.hir().local_def_id_from_hir_id(ctor_id);
|
||||
let param_env = gcx.param_env(def_id);
|
||||
|
||||
// Normalize the sig.
|
||||
|
@ -80,8 +80,8 @@ fn mir_keys<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, krate: CrateNum)
|
||||
_: &'tcx hir::Generics,
|
||||
_: hir::HirId,
|
||||
_: Span) {
|
||||
if let hir::VariantData::Tuple(_, node_id, _) = *v {
|
||||
self.set.insert(self.tcx.hir().local_def_id(node_id));
|
||||
if let hir::VariantData::Tuple(_, hir_id) = *v {
|
||||
self.set.insert(self.tcx.hir().local_def_id_from_hir_id(hir_id));
|
||||
}
|
||||
intravisit::walk_struct_def(self, v)
|
||||
}
|
||||
|
@ -454,7 +454,7 @@ fn convert_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, item_id: hir::HirId) {
|
||||
}
|
||||
|
||||
if !struct_def.is_struct() {
|
||||
convert_variant_ctor(tcx, struct_def.id());
|
||||
convert_variant_ctor(tcx, struct_def.hir_id());
|
||||
}
|
||||
}
|
||||
|
||||
@ -510,8 +510,8 @@ fn convert_impl_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, impl_item_id: hir::H
|
||||
}
|
||||
}
|
||||
|
||||
fn convert_variant_ctor<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, ctor_id: ast::NodeId) {
|
||||
let def_id = tcx.hir().local_def_id(ctor_id);
|
||||
fn convert_variant_ctor<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, ctor_id: hir::HirId) {
|
||||
let def_id = tcx.hir().local_def_id_from_hir_id(ctor_id);
|
||||
tcx.generics_of(def_id);
|
||||
tcx.type_of(def_id);
|
||||
tcx.predicates_of(def_id);
|
||||
@ -563,7 +563,7 @@ fn convert_enum_variant_types<'a, 'tcx>(
|
||||
|
||||
// Convert the ctor, if any. This also registers the variant as
|
||||
// an item.
|
||||
convert_variant_ctor(tcx, variant.node.data.id());
|
||||
convert_variant_ctor(tcx, variant.node.data.hir_id());
|
||||
}
|
||||
}
|
||||
|
||||
@ -634,7 +634,7 @@ fn adt_def<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> &'tcx ty::Ad
|
||||
def.variants
|
||||
.iter()
|
||||
.map(|v| {
|
||||
let did = tcx.hir().local_def_id(v.node.data.id());
|
||||
let did = tcx.hir().local_def_id_from_hir_id(v.node.data.hir_id());
|
||||
let discr = if let Some(ref e) = v.node.disr_expr {
|
||||
distance_from_explicit = 0;
|
||||
ty::VariantDiscr::Explicit(tcx.hir().local_def_id_from_hir_id(e.hir_id))
|
||||
@ -652,7 +652,7 @@ fn adt_def<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> &'tcx ty::Ad
|
||||
ItemKind::Struct(ref def, _) => {
|
||||
// Use separate constructor id for unit/tuple structs and reuse did for braced structs.
|
||||
let ctor_id = if !def.is_struct() {
|
||||
Some(tcx.hir().local_def_id(def.id()))
|
||||
Some(tcx.hir().local_def_id_from_hir_id(def.hir_id()))
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
@ -3088,7 +3088,7 @@ impl Clean<Item> for doctree::Variant {
|
||||
visibility: None,
|
||||
stability: self.stab.clean(cx),
|
||||
deprecation: self.depr.clean(cx),
|
||||
def_id: cx.tcx.hir().local_def_id(self.def.id()),
|
||||
def_id: cx.tcx.hir().local_def_id_from_hir_id(self.def.hir_id()),
|
||||
inner: VariantItem(Variant {
|
||||
kind: self.def.clean(cx),
|
||||
}),
|
||||
|
Loading…
x
Reference in New Issue
Block a user