VariantKind

This commit is contained in:
csmoe 2018-07-11 19:18:57 +08:00 committed by Oliver Schneider
parent 14893ba96b
commit 1d19e0c809
7 changed files with 11 additions and 11 deletions

View File

@ -1507,7 +1507,7 @@ impl<'a> LoweringContext<'a> {
fn lower_variant(&mut self, v: &Variant) -> hir::Variant {
Spanned {
node: hir::Variant_ {
node: hir::VariantKind {
name: v.node.ident.name,
attrs: self.lower_attrs(&v.node.attrs),
data: self.lower_variant_data(&v.node.data),

View File

@ -1176,7 +1176,7 @@ impl<T:Named> Named for Spanned<T> { fn name(&self) -> Name { self.node.name() }
impl Named for Item { fn name(&self) -> Name { self.name } }
impl Named for ForeignItem { fn name(&self) -> Name { self.name } }
impl Named for Variant_ { fn name(&self) -> Name { self.name } }
impl Named for VariantKind { fn name(&self) -> Name { self.name } }
impl Named for StructField { fn name(&self) -> Name { self.ident.name } }
impl Named for TraitItem { fn name(&self) -> Name { self.ident.name } }
impl Named for ImplItem { fn name(&self) -> Name { self.ident.name } }

View File

@ -1878,7 +1878,7 @@ pub struct EnumDef {
}
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub struct Variant_ {
pub struct VariantKind {
pub name: Name,
pub attrs: HirVec<Attribute>,
pub data: VariantData,
@ -1886,7 +1886,7 @@ pub struct Variant_ {
pub disr_expr: Option<AnonConst>,
}
pub type Variant = Spanned<Variant_>;
pub type Variant = Spanned<VariantKind>;
#[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable, Debug)]
pub enum UseKind {

View File

@ -793,14 +793,14 @@ impl_stable_hash_for!(struct hir::EnumDef {
variants
});
impl_stable_hash_for!(struct hir::Variant_ {
impl_stable_hash_for!(struct hir::VariantKind {
name,
attrs,
data,
disr_expr
});
impl_stable_hash_for_spanned!(hir::Variant_);
impl_stable_hash_for_spanned!(hir::VariantKind);
impl_stable_hash_for!(enum hir::UseKind {
Single,

View File

@ -475,7 +475,7 @@ impl<'a, 'tcx> DeadVisitor<'a, 'tcx> {
&& !has_allow_dead_code_or_lang_attr(self.tcx, field.id, &field.attrs)
}
fn should_warn_about_variant(&mut self, variant: &hir::Variant_) -> bool {
fn should_warn_about_variant(&mut self, variant: &hir::VariantKind) -> bool {
!self.symbol_is_live(variant.data.id(), None)
&& !has_allow_dead_code_or_lang_attr(self.tcx,
variant.data.id(),

View File

@ -981,7 +981,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
}
hir::map::NodeVariant(&hir::Variant {
span,
node: hir::Variant_ {
node: hir::VariantKind {
data: hir::VariantData::Tuple(ref fields, _),
..
},

View File

@ -1090,7 +1090,7 @@ fn type_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
}
NodeStructCtor(&ref def) |
NodeVariant(&Spanned { node: hir::Variant_ { data: ref def, .. }, .. }) => {
NodeVariant(&Spanned { node: hir::VariantKind { data: ref def, .. }, .. }) => {
match *def {
VariantData::Unit(..) | VariantData::Struct(..) => {
tcx.type_of(tcx.hir.get_parent_did(node_id))
@ -1123,7 +1123,7 @@ fn type_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
NodeExpr(&hir::Expr { node: ExprRepeat(_, ref constant), .. })
if constant.id == node_id => tcx.types.usize,
NodeVariant(&Spanned { node: Variant_ { disr_expr: Some(ref e), .. }, .. })
NodeVariant(&Spanned { node: VariantKind { disr_expr: Some(ref e), .. }, .. })
if e.id == node_id => {
tcx.adt_def(tcx.hir.get_parent_did(node_id))
.repr.discr_type().to_ty(tcx)
@ -1175,7 +1175,7 @@ fn fn_sig<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
}
NodeStructCtor(&VariantData::Tuple(ref fields, _)) |
NodeVariant(&Spanned { node: hir::Variant_ {
NodeVariant(&Spanned { node: hir::VariantKind {
data: VariantData::Tuple(ref fields, _), ..
}, .. }) => {
let ty = tcx.type_of(tcx.hir.get_parent_did(node_id));