Struct rustc_middle::ty::VariantDef [−][src]
pub struct VariantDef {
pub def_id: DefId,
pub ctor_def_id: Option<DefId>,
pub ident: Ident,
pub discr: VariantDiscr,
pub fields: Vec<FieldDef>,
pub ctor_kind: CtorKind,
flags: VariantFlags,
}Expand description
Definition of a variant – a struct’s fields or a enum variant.
Fields
def_id: DefIdExpand description
DefId that identifies the variant itself.
If this variant belongs to a struct or union, then this is a copy of its DefId.
ctor_def_id: Option<DefId>Expand description
DefId that identifies the variant’s constructor.
If this variant is a struct variant, then this is None.
ident: IdentExpand description
Variant or struct name.
discr: VariantDiscrExpand description
Discriminant of this variant.
fields: Vec<FieldDef>Expand description
Fields of this variant.
ctor_kind: CtorKindExpand description
Type of constructor of variant.
flags: VariantFlagsExpand description
Flags of the variant (e.g. is field list non-exhaustive)?
Implementations
impl<'tcx> VariantDef[src]
impl<'tcx> VariantDef[src]pub fn uninhabited_from(
&self,
tcx: TyCtxt<'tcx>,
substs: SubstsRef<'tcx>,
adt_kind: AdtKind,
param_env: ParamEnv<'tcx>
) -> DefIdForest[src]
pub fn uninhabited_from(
&self,
tcx: TyCtxt<'tcx>,
substs: SubstsRef<'tcx>,
adt_kind: AdtKind,
param_env: ParamEnv<'tcx>
) -> DefIdForest[src]Calculates the forest of DefIds from which this variant is visibly uninhabited.
impl VariantDef[src]
impl VariantDef[src]pub fn new(
ident: Ident,
variant_did: Option<DefId>,
ctor_def_id: Option<DefId>,
discr: VariantDiscr,
fields: Vec<FieldDef>,
ctor_kind: CtorKind,
adt_kind: AdtKind,
parent_did: DefId,
recovered: bool,
is_field_list_non_exhaustive: bool
) -> Self[src]
pub fn new(
ident: Ident,
variant_did: Option<DefId>,
ctor_def_id: Option<DefId>,
discr: VariantDiscr,
fields: Vec<FieldDef>,
ctor_kind: CtorKind,
adt_kind: AdtKind,
parent_did: DefId,
recovered: bool,
is_field_list_non_exhaustive: bool
) -> Self[src]Creates a new VariantDef.
variant_did is the DefId that identifies the enum variant (if this VariantDef
represents an enum variant).
ctor_did is the DefId that identifies the constructor of unit or
tuple-variants/structs. If this is a struct-variant then this should be None.
parent_did is the DefId of the AdtDef representing the enum or struct that
owns this variant. It is used for checking if a struct has #[non_exhaustive] w/out having
to go through the redirect of checking the ctor’s attributes - but compiling a small crate
requires loading the AdtDefs for all the structs in the universe (e.g., coherence for any
built-in trait), and we do not want to load attributes twice.
If someone speeds up attribute loading to not be a performance concern, they can
remove this hack and use the constructor DefId everywhere.
pub fn is_field_list_non_exhaustive(&self) -> bool[src]
pub fn is_field_list_non_exhaustive(&self) -> bool[src]Is this field list non-exhaustive?
pub fn is_recovered(&self) -> bool[src]
pub fn is_recovered(&self) -> bool[src]Was this variant obtained as part of recovering from a syntactic error?
Trait Implementations
impl Debug for VariantDef[src]
impl Debug for VariantDef[src]impl<'__ctx> HashStable<StableHashingContext<'__ctx>> for VariantDef[src]
impl<'__ctx> HashStable<StableHashingContext<'__ctx>> for VariantDef[src]fn hash_stable(
&self,
__hcx: &mut StableHashingContext<'__ctx>,
__hasher: &mut StableHasher
)[src]
&self,
__hcx: &mut StableHashingContext<'__ctx>,
__hasher: &mut StableHasher
)
Auto Trait Implementations
impl RefUnwindSafe for VariantDef
impl !Send for VariantDef
impl !Sync for VariantDef
impl Unpin for VariantDef
impl UnwindSafe for VariantDef
Blanket Implementations
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]pub fn borrow_mut(&mut self) -> &mut T[src]
pub fn borrow_mut(&mut self) -> &mut T[src]Mutably borrows from an owned value. Read more
impl<T> MaybeResult<T> for T[src]
impl<T> MaybeResult<T> for T[src]impl<T> WithConstness for T[src]
impl<T> WithConstness for T[src]fn with_constness(self, constness: Constness) -> ConstnessAnd<Self>[src]
fn with_const(self) -> ConstnessAnd<Self>[src]
fn without_const(self) -> ConstnessAnd<Self>[src]
impl<'a, T> Captures<'a> for T where
T: ?Sized, [src]
T: ?Sized,