rustc_middle::ty::layout

Type Alias TyAndLayout

Source
pub type TyAndLayout<'tcx> = TyAndLayout<'tcx, Ty<'tcx>>;

Aliased Type§

struct TyAndLayout<'tcx> {
    pub ty: Ty<'tcx>,
    pub layout: Layout<'tcx>,
}

Fields§

§ty: Ty<'tcx>§layout: Layout<'tcx>

Implementations

Source§

impl<'a, Ty> TyAndLayout<'a, Ty>

Source

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 1-ZST fields 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>

Source

pub fn for_variant<C>( self, cx: &C, variant_index: VariantIdx, ) -> TyAndLayout<'a, Ty>
where Ty: TyAbiInterface<'a, C>,

Source

pub fn field<C>(self, cx: &C, i: usize) -> TyAndLayout<'a, Ty>
where Ty: TyAbiInterface<'a, C>,

Source

pub fn pointee_info_at<C>(self, cx: &C, offset: Size) -> Option<PointeeInfo>
where Ty: TyAbiInterface<'a, C>,

Source

pub fn is_single_fp_element<C>(self, cx: &C) -> bool
where Ty: TyAbiInterface<'a, C>, C: HasDataLayout,

Source

pub fn is_adt<C>(self) -> bool
where Ty: TyAbiInterface<'a, C>,

Source

pub fn is_never<C>(self) -> bool
where Ty: TyAbiInterface<'a, C>,

Source

pub fn is_tuple<C>(self) -> bool
where Ty: TyAbiInterface<'a, C>,

Source

pub fn is_unit<C>(self) -> bool
where Ty: TyAbiInterface<'a, C>,

Source

pub fn is_transparent<C>(self) -> bool
where Ty: TyAbiInterface<'a, C>,

Source

pub fn non_1zst_field<C>(&self, cx: &C) -> Option<(usize, TyAndLayout<'a, Ty>)>
where Ty: TyAbiInterface<'a, C> + Copy,

Finds the one field that is not a 1-ZST. Returns None if there are multiple non-1-ZST fields or only 1-ZST-fields.

Trait Implementations§

Source§

impl<'tcx> Key for TyAndLayout<'tcx>

Source§

type Cache<V> = DefaultCache<TyAndLayout<'tcx, Ty<'tcx>>, V>

Source§

fn default_span(&self, _: TyCtxt<'_>) -> Span

In the event that a cycle occurs, if no explicit span has been given for a query with key self, what span should we use?
Source§

fn key_as_def_id(&self) -> Option<DefId>

If the key is a DefId or DefId–equivalent, return that DefId. Otherwise, return None.
Source§

fn ty_def_id(&self) -> Option<DefId>

Source§

impl<'a, Ty> Clone for TyAndLayout<'a, Ty>
where Ty: Clone,

Source§

fn clone(&self) -> TyAndLayout<'a, Ty>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a, Ty> Debug for TyAndLayout<'a, Ty>
where Ty: Display,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<'a, Ty> Deref for TyAndLayout<'a, Ty>

Source§

type Target = &'a LayoutData<FieldIdx, VariantIdx>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &&'a LayoutData<FieldIdx, VariantIdx>

Dereferences the value.
Source§

impl<'a, Ty> Hash for TyAndLayout<'a, Ty>
where Ty: Hash,

Source§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<'a, Ty, __CTX> HashStable<__CTX> for TyAndLayout<'a, Ty>
where __CTX: HashStableContext, Ty: HashStable<__CTX>,

Source§

fn hash_stable( &self, __hcx: &mut __CTX, __hasher: &mut StableHasher<SipHasher128>, )

Source§

impl<'a, Ty> PartialEq for TyAndLayout<'a, Ty>
where Ty: PartialEq,

Source§

fn eq(&self, other: &TyAndLayout<'a, Ty>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'tcx> TypeVisitable<TyCtxt<'tcx>> for TyAndLayout<'tcx, Ty<'tcx>>

Source§

fn visit_with<V: TypeVisitor<TyCtxt<'tcx>>>(&self, visitor: &mut V) -> V::Result

The entry point for visiting. To visit a value t with a visitor v call: t.visit_with(v). Read more
Source§

impl<'a, Ty> Copy for TyAndLayout<'a, Ty>
where Ty: Copy,

Source§

impl<'a, Ty> Eq for TyAndLayout<'a, Ty>
where Ty: Eq,

Source§

impl<'a, Ty> StructuralPartialEq for TyAndLayout<'a, Ty>

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: 16 bytes