Struct rustc_middle::ty::VariantDef
source · [−]pub struct VariantDef {
pub def_id: DefId,
pub ctor_def_id: Option<DefId>,
pub name: Symbol,
pub discr: VariantDiscr,
pub fields: Vec<FieldDef>,
pub ctor_kind: CtorKind,
flags: VariantFlags,
}
Expand description
Definition of a variant – a struct’s fields or an enum variant.
Fields
def_id: DefId
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>
DefId
that identifies the variant’s constructor.
If this variant is a struct variant, then this is None
.
name: Symbol
Variant or struct name.
discr: VariantDiscr
Discriminant of this variant.
fields: Vec<FieldDef>
Fields of this variant.
ctor_kind: CtorKind
Type of constructor of variant.
flags: VariantFlags
Flags of the variant (e.g. is field list non-exhaustive)?
Implementations
sourceimpl<'tcx> VariantDef
impl<'tcx> VariantDef
sourcepub fn uninhabited_from(
&self,
tcx: TyCtxt<'tcx>,
substs: SubstsRef<'tcx>,
adt_kind: AdtKind,
param_env: ParamEnv<'tcx>
) -> DefIdForest<'tcx>
pub fn uninhabited_from(
&self,
tcx: TyCtxt<'tcx>,
substs: SubstsRef<'tcx>,
adt_kind: AdtKind,
param_env: ParamEnv<'tcx>
) -> DefIdForest<'tcx>
Calculates the forest of DefId
s from which this variant is visibly uninhabited.
sourceimpl VariantDef
impl VariantDef
sourcepub fn new(
name: Symbol,
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
pub fn new(
name: Symbol,
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 AdtDef
s 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.
sourcepub fn is_field_list_non_exhaustive(&self) -> bool
pub fn is_field_list_non_exhaustive(&self) -> bool
Is this field list non-exhaustive?
sourcepub fn is_recovered(&self) -> bool
pub fn is_recovered(&self) -> bool
Was this variant obtained as part of recovering from a syntactic error?
Trait Implementations
sourceimpl Debug for VariantDef
impl Debug for VariantDef
sourceimpl<'tcx, __D: TyDecoder<I = TyCtxt<'tcx>>> Decodable<__D> for VariantDef
impl<'tcx, __D: TyDecoder<I = TyCtxt<'tcx>>> Decodable<__D> for VariantDef
sourceimpl<'tcx, __E: TyEncoder<I = TyCtxt<'tcx>>> Encodable<__E> for VariantDef
impl<'tcx, __E: TyEncoder<I = TyCtxt<'tcx>>> Encodable<__E> for VariantDef
sourceimpl Hash for VariantDef
impl Hash for VariantDef
sourceimpl<'__ctx> HashStable<StableHashingContext<'__ctx>> for VariantDef
impl<'__ctx> HashStable<StableHashingContext<'__ctx>> for VariantDef
fn hash_stable(
&self,
__hcx: &mut StableHashingContext<'__ctx>,
__hasher: &mut StableHasher
)
sourceimpl PartialEq<VariantDef> for VariantDef
impl PartialEq<VariantDef> for VariantDef
impl Eq for VariantDef
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
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
sourceimpl<Ctxt, T> DepNodeParams<Ctxt> for Twhere
Ctxt: DepContext,
T: for<'a> HashStable<StableHashingContext<'a>> + Debug,
impl<Ctxt, T> DepNodeParams<Ctxt> for Twhere
Ctxt: DepContext,
T: for<'a> HashStable<StableHashingContext<'a>> + Debug,
default fn fingerprint_style() -> FingerprintStyle
sourcedefault fn to_fingerprint(&self, tcx: Ctxt) -> Fingerprint
default fn to_fingerprint(&self, tcx: Ctxt) -> Fingerprint
default fn to_debug_str(&self, Ctxt) -> String
sourcedefault fn recover(Ctxt, &DepNode<<Ctxt as DepContext>::DepKind>) -> Option<T>
default fn recover(Ctxt, &DepNode<<Ctxt as DepContext>::DepKind>) -> Option<T>
DepNode
,
something which is needed when forcing DepNode
s during red-green
evaluation. The query system will only call this method if
fingerprint_style()
is not FingerprintStyle::Opaque
.
It is always valid to return None
here, in which case incremental
compilation will treat the query as having changed instead of forcing it. Read moresourceimpl<T, R> InternIteratorElement<T, R> for T
impl<T, R> InternIteratorElement<T, R> for T
type Output = R
fn intern_with<I, F>(iter: I, f: F) -> <T as InternIteratorElement<T, R>>::Outputwhere
I: Iterator<Item = T>,
F: FnOnce(&[T]) -> R,
sourceimpl<T> MaybeResult<T> for T
impl<T> MaybeResult<T> for T
sourceimpl<CTX, T> Value<CTX> for Twhere
CTX: DepContext,
impl<CTX, T> Value<CTX> for Twhere
CTX: DepContext,
default fn from_cycle_error(tcx: CTX) -> T
impl<'a, T> Captures<'a> for Twhere
T: ?Sized,
Layout
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference’s “Type Layout” chapter for details on type layout guarantees.
Size: 64 bytes