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

Calculates the forest of DefIds from which this variant is visibly uninhabited.

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.

Is this field list non-exhaustive?

Was this variant obtained as part of recovering from a syntactic error?

Computes the Ident of this variant by looking up the Span

Trait Implementations

Formats the value using the given formatter. Read more
Feeds this value into the given Hasher. Read more
Feeds a slice of this type into the given Hasher. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
This method turns the parameters of a DepNodeConstructor into an opaque Fingerprint to be used in DepNode. Not all DepNodeParams support being turned into a Fingerprint (they don’t need to if the corresponding DepNode is anonymous). Read more
This method tries to recover the query key from the given DepNode, something which is needed when forcing DepNodes 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 more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.

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