Navigation Menu

Skip to content

Commit

Permalink
VariantKind
Browse files Browse the repository at this point in the history
  • Loading branch information
csmoe authored and oli-obk committed Jul 16, 2018
1 parent 14893ba commit 1d19e0c
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/librustc/hir/lowering.rs
Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/hir/map/mod.rs
Expand Up @@ -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 } }
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/hir/mod.rs
Expand Up @@ -1878,15 +1878,15 @@ pub struct EnumDef {
}

#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub struct Variant_ {
pub struct VariantKind {
pub name: Name,
pub attrs: HirVec<Attribute>,
pub data: VariantData,
/// Explicit discriminant, eg `Foo = 1`
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 {
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/ich/impls_hir.rs
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/dead.rs
Expand Up @@ -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(),
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/traits/error_reporting.rs
Expand Up @@ -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, _),
..
},
Expand Down
6 changes: 3 additions & 3 deletions src/librustc_typeck/collect.rs
Expand Up @@ -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))
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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));
Expand Down

0 comments on commit 1d19e0c

Please sign in to comment.