[][src]Struct rustc::ty::VariantDef

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,
    pub recovered: bool,
}
⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

Definition of a variant -- a struct's fields or a enum variant.

Fields

def_id: DefId
⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

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>
⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

DefId that identifies the variant's constructor. If this variant is a struct variant, then this is None.

ident: Ident
⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

Variant or struct name.

discr: VariantDiscr
⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

Discriminant of this variant.

fields: Vec<FieldDef>
⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

Fields of this variant.

ctor_kind: CtorKind
⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

Type of constructor of variant.

flags: VariantFlags
⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

Flags of the variant (e.g. is field list non-exhaustive)?

recovered: bool
⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

Variant is obtained as part of recovering from a syntactic error. May be incomplete or bogus.

Methods

impl<'tcx> VariantDef[src]

pub fn uninhabited_from(
    &self,
    tcx: TyCtxt<'tcx>,
    substs: SubstsRef<'tcx>,
    adt_kind: AdtKind
) -> DefIdForest
[src]

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

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

impl<'tcx> VariantDef[src]

pub fn new(
    tcx: TyCtxt<'tcx>,
    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
) -> Self
[src]

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

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]

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

Is this field list non-exhaustive?

Trait Implementations

impl Debug for VariantDef[src]

impl<'__ctx> HashStable<StableHashingContext<'__ctx>> for VariantDef[src]

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]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<'a, T> Captures<'a> for T where
    T: ?Sized
[src]

impl<T> Erased for T[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> MaybeResult<T> for T[src]

type Error = !

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

impl<E> SpecializationError for E[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.