pub struct AdtDefData {
pub did: DefId,
variants: IndexVec<VariantIdx, VariantDef>,
flags: AdtFlags,
repr: ReprOptions,
}
Expand description
The definition of a user-defined type, e.g., a struct
, enum
, or union
.
These are all interned (by mk_adt_def
) into the global arena.
The initialism ADT stands for an algebraic data type (ADT).
This is slightly wrong because union
s are not ADTs.
Moreover, Rust only allows recursive data types through indirection.
§Recursive types
It may seem impossible to represent recursive types using Ty
,
since TyKind::Adt
includes AdtDef
, which includes its fields,
creating a cycle. However, AdtDef
does not actually include the types
of its fields; it includes just their DefId
s.
For example, the following type:
struct S { x: Box<S> }
is essentially represented with Ty
as the following pseudocode:
struct S { x }
where x
here represents the DefId
of S.x
. Then, the DefId
can be used with TyCtxt::type_of()
to get the type of the field.
Fields§
§did: DefId
The DefId
of the struct, enum or union item.
variants: IndexVec<VariantIdx, VariantDef>
Variants of the ADT. If this is a struct or union, then there will be a single variant.
flags: AdtFlags
Flags of the ADT (e.g., is this a struct? is this non-exhaustive?).
repr: ReprOptions
Repr options provided by the user.
Implementations§
Source§impl AdtDefData
impl AdtDefData
Sourcepub(super) fn new(
tcx: TyCtxt<'_>,
did: DefId,
kind: AdtKind,
variants: IndexVec<VariantIdx, VariantDef>,
repr: ReprOptions,
) -> Self
pub(super) fn new( tcx: TyCtxt<'_>, did: DefId, kind: AdtKind, variants: IndexVec<VariantIdx, VariantDef>, repr: ReprOptions, ) -> Self
Creates a new AdtDefData
.
Trait Implementations§
Source§impl<'tcx> ArenaAllocatable<'tcx> for AdtDefData
impl<'tcx> ArenaAllocatable<'tcx> for AdtDefData
fn allocate_on(self, arena: &'tcx Arena<'tcx>) -> &'tcx mut Self
fn allocate_from_iter( arena: &'tcx Arena<'tcx>, iter: impl IntoIterator<Item = Self>, ) -> &'tcx mut [Self]
Source§impl<'tcx> Borrow<AdtDefData> for InternedInSet<'tcx, AdtDefData>
impl<'tcx> Borrow<AdtDefData> for InternedInSet<'tcx, AdtDefData>
Source§fn borrow<'a>(&'a self) -> &'a AdtDefData
fn borrow<'a>(&'a self) -> &'a AdtDefData
Source§impl<__D: TyDecoder> Decodable<__D> for AdtDefData
impl<__D: TyDecoder> Decodable<__D> for AdtDefData
Source§impl<__E: TyEncoder> Encodable<__E> for AdtDefData
impl<__E: TyEncoder> Encodable<__E> for AdtDefData
Source§impl Hash for AdtDefData
There should be only one AdtDef for each did
, therefore
it is fine to implement Hash
only based on did
.
impl Hash for AdtDefData
There should be only one AdtDef for each did
, therefore
it is fine to implement Hash
only based on did
.
Source§impl<'a> HashStable<StableHashingContext<'a>> for AdtDefData
impl<'a> HashStable<StableHashingContext<'a>> for AdtDefData
fn hash_stable( &self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher, )
Source§impl PartialEq for AdtDefData
impl PartialEq for AdtDefData
Source§impl<'tcx, D: TyDecoder<I = TyCtxt<'tcx>>> RefDecodable<'tcx, D> for AdtDefData
impl<'tcx, D: TyDecoder<I = TyCtxt<'tcx>>> RefDecodable<'tcx, D> for AdtDefData
impl Eq for AdtDefData
Auto Trait Implementations§
impl DynSend for AdtDefData
impl DynSync for AdtDefData
impl Freeze for AdtDefData
impl RefUnwindSafe for AdtDefData
impl Send for AdtDefData
impl Sync for AdtDefData
impl Unpin for AdtDefData
impl UnwindSafe for AdtDefData
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T, R> CollectAndApply<T, R> for T
impl<T, R> CollectAndApply<T, R> for T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.Source§impl<T> Filterable for T
impl<T> Filterable for T
Source§fn filterable(
self,
filter_name: &'static str,
) -> RequestFilterDataProvider<T, fn(_: DataRequest<'_>) -> bool>
fn filterable( self, filter_name: &'static str, ) -> RequestFilterDataProvider<T, fn(_: DataRequest<'_>) -> bool>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§impl<P> IntoQueryParam<P> for P
impl<P> IntoQueryParam<P> for P
fn into_query_param(self) -> P
Source§impl<T> MaybeResult<T> for T
impl<T> MaybeResult<T> for T
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<I, T, U> Upcast<I, U> for Twhere
U: UpcastFrom<I, T>,
impl<I, T, U> Upcast<I, U> for Twhere
U: UpcastFrom<I, T>,
Source§impl<I, T> UpcastFrom<I, T> for T
impl<I, T> UpcastFrom<I, T> for T
fn upcast_from(from: T, _tcx: I) -> T
Source§impl<Tcx, T> Value<Tcx> for Twhere
Tcx: DepContext,
impl<Tcx, T> Value<Tcx> for Twhere
Tcx: DepContext,
default fn from_cycle_error( tcx: Tcx, cycle_error: &CycleError, _guar: ErrorGuaranteed, ) -> T
Source§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
Source§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
Source§fn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
impl<'a, T> Captures<'a> for Twhere
T: ?Sized,
impl<T> ErasedDestructor for Twhere
T: 'static,
impl<T> MaybeSendSync for T
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: 56 bytes