Skip to main content

ThunkSignature

Struct ThunkSignature 

Source
pub struct ThunkSignature {
    pub impl_type_id: u32,
    pub trait_id: u32,
    pub method_name: String,
    pub flags: VTableEntryFlags,
    pub wrap_targets: SmallVec<[WrapTarget; 2]>,
    pub self_arg_positions: SmallVec<[u8; 4]>,
    pub type_param_count: u8,
}
Expand description

Per-(impl, method) thunk descriptor — the data the emission tier needs to generate a thunk function for one method of one impl.

The emission tier walks each impl’s method list, runs Erase_T on each method’s signature, and either emits a VTableEntry::Direct (no rewriting needed) or a thunk + the corresponding VTableEntry::{BoxedReturn, SelfArg, Generic, Compound} per §Q25.C.5.

Per-(impl, method) cardinality. One thunk per pair, NOT one per trait — different impls of the same trait method may need different thunks because the concrete return type differs. (E.g. impl Animal for Dog { fn clone_me(&self) -> Dog } vs impl Animal for Cat { fn clone_me(&self) -> Cat } — each clones a different concrete type and boxes it under the same trait id.)

Fields§

§impl_type_id: u32

Impl that owns the method (concrete-type id from the impl’s matching VTable::concrete_type_id).

§trait_id: u32

Trait the method belongs to (VTable::trait_names first entry, or the surrounding trait for multi-impl cases).

§method_name: String

Method name as declared in the trait.

§flags: VTableEntryFlags

Erasure flags — which of (BoxedReturn / SelfArg / Generic) apply. Empty → emission tier emits VTableEntry::Direct and no thunk. Single bit → emission emits the corresponding single-shape VTableEntry::* variant. Multiple bits → VTableEntry::Compound.

§wrap_targets: SmallVec<[WrapTarget; 2]>

Wrap-targets if BOXED_RETURN is set (empty otherwise).

§self_arg_positions: SmallVec<[u8; 4]>

Self-arg positions if SELF_ARG is set (empty otherwise).

§type_param_count: u8

Number of method-generic parameters if GENERIC is set (zero otherwise).

Implementations§

Source§

impl ThunkSignature

Source

pub fn build( impl_type_id: u32, trait_id: u32, method_name: String, return_wrap_targets: SmallVec<[WrapTarget; 2]>, self_arg_positions: SmallVec<[u8; 4]>, type_param_count: u8, ) -> Self

Build a thunk signature from per-arg / per-return erasure results. The emission tier calls this once per (impl, method) pair after running Erase_T on each component of the signature.

  • return_wrap_targetswrap_targets from running Erase_T on the method’s return type. Non-empty ⇒ BOXED_RETURN.
  • self_arg_positions — indices (0-based, excluding receiver) of arguments declared as Self in the trait signature. Non-empty ⇒ SELF_ARG.
  • type_param_count — number of <G> method-generic parameters. Non-zero ⇒ GENERIC.
Source

pub fn is_direct(&self) -> bool

Whether this method needs no thunk at all (Direct dispatch).

Source

pub fn to_vtable_entry(&self, function_or_thunk_id: u16) -> VTableEntry

Build the corresponding VTableEntry once the emission tier has assigned function_id (for Direct) / thunk_id (otherwise). Direct entries get function_id; Compound / shape entries get the thunk id and the emission-tier- allocated thunk function id is stored elsewhere.

Trait Implementations§

Source§

impl Clone for ThunkSignature

Source§

fn clone(&self) -> ThunkSignature

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for ThunkSignature

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,