Struct MirFunction

Source
pub struct MirFunction {
    pub name: String,
    pub arity: usize,
    pub return_ty: Ty,
    pub locals: PrimaryMap<MirLocalId, LocalInfo>,
    pub params: Vec<MirLocalId>,
    pub param_modes: Vec<MirOwnershipMode>,
    pub entry: MirBlockId,
    pub blocks: PrimaryMap<MirBlockId, MirBlock>,
}
Expand description

Function-level MIR in CFG form.

  • params are function parameter locals.
  • param_modes mirrors source ownership modes for parameters.
  • entry is the first block reached for execution.

Fields§

§name: String

User-visible function or field name.

§arity: usize

Number of source parameters accepted by the function.

§return_ty: Ty

Semantic return type of the function.

§locals: PrimaryMap<MirLocalId, LocalInfo>

Local metadata arena for function values.

§params: Vec<MirLocalId>

Local ids corresponding to incoming parameters.

§param_modes: Vec<MirOwnershipMode>

Ownership modes for each incoming parameter.

§entry: MirBlockId

Entry block id for the function CFG.

§blocks: PrimaryMap<MirBlockId, MirBlock>

CFG blocks stored for the function.

Implementations§

Source§

impl MirFunction

Source

pub fn param_binding(&self, index: usize) -> MirParamBinding<'_>

Return metadata for one parameter by index.

Source

pub fn param_bindings(&self) -> impl Iterator<Item = MirParamBinding<'_>> + '_

Iterate over source parameters with normalized query helpers.

Source

pub fn local_info(&self, local_id: MirLocalId) -> &LocalInfo

Return metadata for one local.

Source

pub fn call_arg_binding<'a>( &'a self, arg: &'a MirCallArg, ) -> MirCallArgBinding<'a>

Return normalized metadata for one call argument.

Source

pub fn assert_valid(&self)

Assert internal MIR invariants needed by downstream backends.

Source

fn assert_edge_args_compatible( &self, params: &[MirLocalId], args: &[MirLocalId], edge_kind: &'static str, )

Assert that edge arguments match the target block parameter contract.

Source

fn assert_instr_valid(&self, instr: &MirInstr)

Assert per-instruction MIR invariants.

Source

fn assert_call_args_valid(&self, args: &[MirCallArg])

Assert call argument invariants that are backend-independent.

Trait Implementations§

Source§

impl Clone for MirFunction

Source§

fn clone(&self) -> MirFunction

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 Debug for MirFunction

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.