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