[][src]Struct rustc::ty::AdtDef

pub struct AdtDef {
    pub did: DefId,
    pub variants: IndexVec<VariantIdx, VariantDef>,
    flags: AdtFlags,
    pub repr: ReprOptions,
}
⚙️ 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.

The definition of a user-defined type, e.g., a struct, enum, or union.

These are all interned (by intern_adt_def) into the adt_defs table.

The initialism ADT stands for an algebraic data type (ADT). This is slightly wrong because unions are not ADTs. Moreover, Rust only allows recursive data types through indirection.

Fields

did: 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.

The DefId of the struct, enum or union item.

variants: IndexVec<VariantIdx, VariantDef>
⚙️ 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.

Variants of the ADT. If this is a struct or union, then there will be a single variant.

flags: AdtFlags
⚙️ 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 ADT (e.g., is this a struct? is this non-exhaustive?).

repr: ReprOptions
⚙️ 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.

Repr options provided by the user.

Methods

impl<'tcx> AdtDef[src]

fn uninhabited_from(
    &self,
    tcx: TyCtxt<'tcx>,
    substs: SubstsRef<'tcx>
) -> 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 ADT is visibly uninhabited.

impl<'tcx> AdtDef[src]

fn new(
    tcx: TyCtxt,
    did: DefId,
    kind: AdtKind,
    variants: IndexVec<VariantIdx, VariantDef>,
    repr: ReprOptions
) -> 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 AdtDef.

pub fn is_struct(&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.

Returns true if this is a struct.

pub fn is_union(&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.

Returns true if this is a union.

pub fn is_enum(&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.

Returns true if this is a enum.

pub fn is_variant_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.

Returns true if the variant list of this ADT is #[non_exhaustive].

pub fn adt_kind(&self) -> AdtKind[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.

Returns the kind of the ADT.

pub fn descr(&self) -> &'static str[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.

Returns a description of this abstract data type.

pub fn variant_descr(&self) -> &'static str[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.

Returns a description of a variant of this abstract data type.

pub fn has_ctor(&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.

If this function returns true, it implies that is_struct must return true.

pub fn is_fundamental(&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.

Returns true if this type is #[fundamental] for the purposes of coherence checking.

pub fn is_phantom_data(&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.

Returns true if this is PhantomData<T>.

pub fn is_arc(&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.

Returns true if this is Arc<T>.

pub fn is_rc(&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.

Returns true if this is Rc<T>.

pub fn is_box(&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.

Returns true if this is Box.

pub fn has_dtor(&self, tcx: TyCtxt<'tcx>) -> 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.

Returns true if this type has a destructor.

pub fn non_enum_variant(&self) -> &VariantDef[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.

Asserts this is a struct or union and returns its unique variant.

pub fn predicates(&self, tcx: TyCtxt<'tcx>) -> GenericPredicates<'tcx>[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.

pub fn all_fields(&self) -> impl Iterator<Item = &FieldDef> + Clone[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.

Returns an iterator over all fields contained by this ADT.

pub fn is_payloadfree(&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.

pub fn variant_with_id(&self, vid: DefId) -> &VariantDef[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.

Return a VariantDef given a variant id.

pub fn variant_with_ctor_id(&self, cid: DefId) -> &VariantDef[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.

Return a VariantDef given a constructor id.

pub fn variant_index_with_id(&self, vid: DefId) -> VariantIdx[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.

Return the index of VariantDef given a variant id.

pub fn variant_index_with_ctor_id(&self, cid: DefId) -> VariantIdx[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.

Return the index of VariantDef given a constructor id.

pub fn variant_of_res(&self, res: Res) -> &VariantDef[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.

pub fn eval_explicit_discr(
    &self,
    tcx: TyCtxt<'tcx>,
    expr_did: DefId
) -> Option<Discr<'tcx>>
[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.

pub fn discriminants(
    &'tcx self,
    tcx: TyCtxt<'tcx>
) -> impl Iterator<Item = (VariantIdx, Discr<'tcx>)> + Captures<'tcx>
[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.

pub fn variant_range(&self) -> Range<VariantIdx>[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.

pub fn discriminant_for_variant(
    &self,
    tcx: TyCtxt<'tcx>,
    variant_index: VariantIdx
) -> Discr<'tcx>
[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.

Computes the discriminant value used by a specific variant. Unlike discriminants, this is (amortized) constant-time, only doing at most one query for evaluating an explicit discriminant (the last one before the requested variant), assuming there are no constant-evaluation errors there.

pub fn discriminant_def_for_variant(
    &self,
    variant_index: VariantIdx
) -> (Option<DefId>, u32)
[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.

Yields a DefId for the discriminant and an offset to add to it Alternatively, if there is no explicit discriminant, returns the inferred discriminant directly.

pub fn destructor(&self, tcx: TyCtxt<'tcx>) -> Option<Destructor>[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.

pub fn sized_constraint(&self, tcx: TyCtxt<'tcx>) -> &'tcx [Ty<'tcx>][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.

Returns a list of types such that Self: Sized if and only if that type is Sized, or TyErr if this type is recursive.

Oddly enough, checking that the sized-constraint is Sized is actually more expressive than checking all members: the Sized trait is inductive, so an associated type that references Self would prevent its containing ADT from being Sized.

Due to normalization being eager, this applies even if the associated type is behind a pointer (e.g., issue #31299).

Trait Implementations

impl ArenaAllocatable for AdtDef[src]

impl<'tcx> ArenaField<'tcx> for AdtDef[src]

impl Debug for AdtDef[src]

impl Eq for AdtDef[src]

impl Hash for AdtDef[src]

impl<'a> HashStable<StableHashingContext<'a>> for AdtDef[src]

impl Ord for AdtDef[src]

There should be only one AdtDef for each did, therefore it is fine to implement Ord only based on did.

impl PartialEq<AdtDef> for AdtDef[src]

impl PartialOrd<AdtDef> for AdtDef[src]

impl<'a, 'tcx> SpecializedDecoder<&'tcx AdtDef> for CacheDecoder<'a, 'tcx>[src]

impl<'tcx> TypeFoldable<'tcx> for &'tcx AdtDef[src]

AdtDefs are basically the same as a DefId.

impl<'tcx> UseSpecializedDecodable for &'tcx AdtDef[src]

impl<'tcx> UseSpecializedEncodable for &'tcx AdtDef[src]

Auto Trait Implementations

impl RefUnwindSafe for AdtDef

impl !Send for AdtDef

impl !Sync for AdtDef

impl Unpin for AdtDef

impl UnwindSafe for AdtDef

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> ArenaAllocatable for T where
    T: Copy
[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<Q, K> Equivalent<K> for Q where
    K: Borrow<Q> + ?Sized,
    Q: Eq + ?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.