Struct rustc_target::abi::TyAndLayout [−][src]
pub struct TyAndLayout<'a, Ty> {
pub ty: Ty,
pub layout: &'a Layout,
}
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: &'a Layout
Implementations
pub 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.
pub fn for_variant<C>(self, cx: &C, variant_index: VariantIdx) -> Self where
Ty: TyAbiInterface<'a, C>,
pub fn pointee_info_at<C>(self, cx: &C, offset: Size) -> Option<PointeeInfo> where
Ty: TyAbiInterface<'a, C>,
Returns true
if the layout corresponds to an unsized type.
pub fn might_permit_raw_init<C>(self, cx: &C, zero: bool) -> bool where
Self: Copy,
Ty: TyAbiInterface<'a, C>,
C: HasDataLayout,
pub fn might_permit_raw_init<C>(self, cx: &C, zero: bool) -> bool where
Self: Copy,
Ty: TyAbiInterface<'a, C>,
C: HasDataLayout,
Determines if this type permits “raw” initialization by just transmuting some
memory into an instance of T
.
zero
indicates if the memory is zero-initialized, or alternatively
left entirely uninitialized.
This is conservative: in doubt, it will answer true
.
FIXME: Once we removed all the conservatism, we could alternatively create an all-0/all-undef constant and run the const value validator to see if this is a valid value for the given type.
Methods from Deref<Target = &'a Layout>
Trait Implementations
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>,
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
This method tests for !=
.
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
Mutably borrows from an owned value. Read more
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.