Struct rustc::ty::AdtDef
[−]
[src]
pub struct AdtDef { pub did: DefId, pub variants: Vec<VariantDef>, pub repr: ReprOptions, // some fields omitted }
rustc_private
)The definition of an abstract data type - a struct or enum.
These are all interned (by intern_adt_def) into the adt_defs table.
Fields
did: DefId
rustc_private
)variants: Vec<VariantDef>
rustc_private
)repr: ReprOptions
rustc_private
)Methods
impl<'a, 'gcx, 'tcx> AdtDef
[src]
fn uninhabited_from(&self,
visited: &mut FxHashMap<DefId, FxHashSet<&'tcx Substs<'tcx>>>,
tcx: TyCtxt<'a, 'gcx, 'tcx>,
substs: &'tcx Substs<'tcx>)
-> DefIdForest
visited: &mut FxHashMap<DefId, FxHashSet<&'tcx Substs<'tcx>>>,
tcx: TyCtxt<'a, 'gcx, 'tcx>,
substs: &'tcx Substs<'tcx>)
-> DefIdForest
rustc_private
)Calculate the forest of DefIds from which this adt is visibly uninhabited.
impl<'a, 'gcx, 'tcx> AdtDef
[src]
fn is_struct(&self) -> bool
rustc_private
)fn is_union(&self) -> bool
rustc_private
)fn is_enum(&self) -> bool
rustc_private
)fn adt_kind(&self) -> AdtKind
rustc_private
)Returns the kind of the ADT - Struct or Enum.
fn descr(&self) -> &'static str
rustc_private
)fn variant_descr(&self) -> &'static str
rustc_private
)fn is_dtorck(&'gcx self, tcx: TyCtxt) -> bool
rustc_private
)Returns whether this is a dtorck type. If this returns true, this type being safe for destruction requires it to be alive; Otherwise, only the contents are required to be.
fn is_fundamental(&self) -> bool
rustc_private
)Returns whether this type is #[fundamental] for the purposes of coherence checking.
fn is_phantom_data(&self) -> bool
rustc_private
)Returns true if this is PhantomData
fn is_box(&self) -> bool
rustc_private
)Returns true if this is Box
fn has_dtor(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> bool
rustc_private
)Returns whether this type has a destructor.
fn struct_variant(&self) -> &VariantDef
rustc_private
)Asserts this is a struct and returns the struct's unique variant.
fn predicates(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> GenericPredicates<'gcx>
rustc_private
)fn all_fields<'s>(&'s self) -> impl Iterator<Item=&'s FieldDef>
rustc_private
)Returns an iterator over all fields contained by this ADT.
fn is_univariant(&self) -> bool
rustc_private
)fn is_payloadfree(&self) -> bool
rustc_private
)fn variant_with_id(&self, vid: DefId) -> &VariantDef
rustc_private
)fn variant_index_with_id(&self, vid: DefId) -> usize
rustc_private
)fn variant_of_def(&self, def: Def) -> &VariantDef
rustc_private
)fn discriminants(&'a self,
tcx: TyCtxt<'a, 'gcx, 'tcx>)
-> impl Iterator<Item=ConstInt> + 'a
tcx: TyCtxt<'a, 'gcx, 'tcx>)
-> impl Iterator<Item=ConstInt> + 'a
rustc_private
)fn destructor(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> Option<Destructor>
rustc_private
)fn sized_constraint(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> Ty<'tcx>
rustc_private
)Returns a simpler type such that Self: Sized
if and only
if that type is Sized, or TyErr
if this type is recursive.
HACK: instead of returning a list of types, this function can return a tuple. In that case, the result is Sized only if all elements of the tuple are Sized.
This is generally the struct_tail
if this is a struct, or a
tuple of them if this is an enum.
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 PartialEq for AdtDef
[src]
fn eq(&self, other: &Self) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0
This method tests for !=
.
impl Eq for AdtDef
[src]
impl Hash for AdtDef
[src]
fn hash<H: Hasher>(&self, s: &mut H)
Feeds this value into the state given, updating the hasher as necessary.
fn hash_slice<H>(data: &[Self], state: &mut H) where H: Hasher
1.3.0
Feeds a slice of this type into the state provided.
impl<'tcx> UseSpecializedEncodable for &'tcx AdtDef
[src]
fn default_encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error>
🔬 This is a nightly-only experimental API. (rustc_private
)
deprecated in favor of rustc-serialize on crates.io
Defaults to returning an error (see SpecializationError
).
impl<'tcx> UseSpecializedDecodable for &'tcx AdtDef
[src]
fn default_decode<D>(&mut D) -> Result<Self, D::Error> where D: Decoder
🔬 This is a nightly-only experimental API. (rustc_private
)
deprecated in favor of rustc-serialize on crates.io
Defaults to returning an error (see SpecializationError
).