Struct rustc_target::abi::TyAndLayout
source · pub struct TyAndLayout<'a, Ty> {
pub ty: Ty,
pub layout: Layout<'a>,
}
Expand description
The layout of a type, alongside the type itself. Provides various type traversal APIs (e.g., recursing into fields).
Note that the layout is NOT guaranteed to always be identical
to that obtained from layout_of(ty)
, as we need to produce
layouts for which Rust types do not exist, such as enum variants
or synthetic fields of enums (i.e., discriminants) and fat pointers.
Fields§
§ty: Ty
§layout: Layout<'a>
Implementations§
source§impl<'a, Ty> TyAndLayout<'a, Ty>
impl<'a, Ty> TyAndLayout<'a, Ty>
fn is_aggregate(&self) -> bool
sourcepub fn homogeneous_aggregate<C>(
&self,
cx: &C
) -> Result<HomogeneousAggregate, Heterogeneous>where
Ty: TyAbiInterface<'a, C> + Copy,
pub fn homogeneous_aggregate<C>(
&self,
cx: &C
) -> Result<HomogeneousAggregate, Heterogeneous>where
Ty: TyAbiInterface<'a, C> + Copy,
Returns Homogeneous
if this layout is an aggregate containing fields of
only a single type (e.g., (u32, u32)
). Such aggregates are often
special-cased in ABIs.
Note: We generally ignore fields of zero-sized type when computing this value (see #56877).
This is public so that it can be used in unit tests, but should generally only be relevant to the ABI details of specific targets.
source§impl<'a, Ty> TyAndLayout<'a, Ty>
impl<'a, Ty> TyAndLayout<'a, Ty>
pub fn for_variant<C>(self, cx: &C, variant_index: VariantIdx) -> Selfwhere
Ty: TyAbiInterface<'a, C>,
pub fn field<C>(self, cx: &C, i: usize) -> Selfwhere
Ty: TyAbiInterface<'a, C>,
pub fn pointee_info_at<C>(self, cx: &C, offset: Size) -> Option<PointeeInfo>where
Ty: TyAbiInterface<'a, C>,
pub fn is_single_fp_element<C>(self, cx: &C) -> boolwhere
Ty: TyAbiInterface<'a, C>,
C: HasDataLayout,
pub fn is_adt<C>(self) -> boolwhere
Ty: TyAbiInterface<'a, C>,
pub fn is_never<C>(self) -> boolwhere
Ty: TyAbiInterface<'a, C>,
pub fn is_tuple<C>(self) -> boolwhere
Ty: TyAbiInterface<'a, C>,
pub fn is_unit<C>(self) -> boolwhere
Ty: TyAbiInterface<'a, C>,
Trait Implementations§
source§impl<'a, Ty: Clone> Clone for TyAndLayout<'a, Ty>
impl<'a, Ty: Clone> Clone for TyAndLayout<'a, Ty>
source§fn clone(&self) -> TyAndLayout<'a, Ty>
fn clone(&self) -> TyAndLayout<'a, Ty>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<'a, Ty: Debug> Debug for TyAndLayout<'a, Ty>
impl<'a, Ty: Debug> Debug for TyAndLayout<'a, Ty>
source§impl<'a, Ty> Deref for TyAndLayout<'a, Ty>
impl<'a, Ty> Deref for TyAndLayout<'a, Ty>
§type Target = &'a LayoutS<VariantIdx>
type Target = &'a LayoutS<VariantIdx>
source§fn deref(&self) -> &&'a LayoutS<VariantIdx>
fn deref(&self) -> &&'a LayoutS<VariantIdx>
source§impl<'a, Ty: Hash> Hash for TyAndLayout<'a, Ty>
impl<'a, Ty: Hash> Hash for TyAndLayout<'a, Ty>
source§impl<'a, Ty, __CTX> HashStable<__CTX> for TyAndLayout<'a, Ty>where
__CTX: HashStableContext,
Ty: HashStable<__CTX>,
impl<'a, Ty, __CTX> HashStable<__CTX> for TyAndLayout<'a, Ty>where
__CTX: HashStableContext,
Ty: HashStable<__CTX>,
fn hash_stable(&self, __hcx: &mut __CTX, __hasher: &mut StableHasher)
source§impl<'a, Ty: PartialEq> PartialEq<TyAndLayout<'a, Ty>> for TyAndLayout<'a, Ty>
impl<'a, Ty: PartialEq> PartialEq<TyAndLayout<'a, Ty>> for TyAndLayout<'a, Ty>
source§fn eq(&self, other: &TyAndLayout<'a, Ty>) -> bool
fn eq(&self, other: &TyAndLayout<'a, Ty>) -> bool
impl<'a, Ty: Copy> Copy for TyAndLayout<'a, Ty>
impl<'a, Ty: Eq> Eq for TyAndLayout<'a, Ty>
impl<'a, Ty> StructuralEq for TyAndLayout<'a, Ty>
impl<'a, Ty> StructuralPartialEq for TyAndLayout<'a, Ty>
Auto Trait Implementations§
impl<'a, Ty> RefUnwindSafe for TyAndLayout<'a, Ty>where
Ty: RefUnwindSafe,
impl<'a, Ty> Send for TyAndLayout<'a, Ty>where
Ty: Send,
impl<'a, Ty> Sync for TyAndLayout<'a, Ty>where
Ty: Sync,
impl<'a, Ty> Unpin for TyAndLayout<'a, Ty>where
Ty: Unpin,
impl<'a, Ty> UnwindSafe for TyAndLayout<'a, Ty>where
Ty: UnwindSafe,
Blanket Implementations§
Layout§
Note: Unable to compute type layout, possibly due to this type having generic parameters. Layout can only be computed for concrete, fully-instantiated types.