[−][src]Struct rustc_middle::ty::VariantDef
Definition of a variant -- a struct's fields or a enum variant.
Fields
def_id: DefIdDefId 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>DefId that identifies the variant's constructor.
If this variant is a struct variant, then this is None.
ident: IdentVariant or struct name.
discr: VariantDiscrDiscriminant of this variant.
fields: Vec<FieldDef>Fields of this variant.
ctor_kind: CtorKindType of constructor of variant.
flags: VariantFlagsFlags of the variant (e.g. is field list non-exhaustive)?
Implementations
impl<'tcx> VariantDef[src]
pub fn uninhabited_from(
&self,
tcx: TyCtxt<'tcx>,
substs: SubstsRef<'tcx>,
adt_kind: AdtKind,
param_env: ParamEnv<'tcx>
) -> DefIdForest[src]
&self,
tcx: TyCtxt<'tcx>,
substs: SubstsRef<'tcx>,
adt_kind: AdtKind,
param_env: ParamEnv<'tcx>
) -> DefIdForest
Calculates the forest of DefIds from which this variant is visibly uninhabited.
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]
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
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]
Is this field list non-exhaustive?
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<'__ctx> HashStable<StableHashingContext<'__ctx>> for VariantDef[src]
pub 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> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T[src]
impl<'a, T> Captures<'a> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T> MaybeResult<T> for T[src]
type Error = !
pub fn from(Result<T, <T as MaybeResult<T>>::Error>) -> T[src]
pub fn to_result(self) -> Result<T, <T as MaybeResult<T>>::Error>[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.