Skip to main content

MirFunction

Struct MirFunction 

Source
pub struct MirFunction {
    pub id: MirFnId,
    pub name: String,
    pub type_params: Vec<(String, Vec<String>)>,
    pub params: Vec<MirParam>,
    pub return_type: Option<String>,
    pub body: MirBody,
    pub is_nogc: bool,
    pub cfg_body: Option<MirCfg>,
    pub decorators: Vec<String>,
    pub vis: Visibility,
}
Expand description

A MIR function definition.

Contains both the tree-form MirBody and an optional CFG representation. The tree-form body is canonical after lowering; the CFG is built on demand via build_cfg for analyses that require explicit control-flow edges (SSA, dominators, loop analysis).

Lambda-lifted closures and the synthetic __main entry function are represented as regular MirFunction instances.

Fields§

§id: MirFnId

Unique function ID within the program.

§name: String

Function name. Lambda-lifted closures use __closure_N names. Impl methods use Target.method qualified names.

§type_params: Vec<(String, Vec<String>)>

Generic type parameters as (param_name, trait_bounds) pairs.

§params: Vec<MirParam>

Function parameters in declaration order.

§return_type: Option<String>

Return type name, if explicitly annotated.

§body: MirBody

Tree-form function body (statements + optional tail expression).

§is_nogc: bool

Whether this function is annotated with @nogc. When true, the nogc_verify module rejects any GC-triggering operations.

§cfg_body: Option<MirCfg>

CFG representation of this function’s body. Built lazily from tree-form body via build_cfg(). When present, this is the canonical representation for the CFG executor.

§decorators: Vec<String>

Decorator names applied to this function (e.g., @memoize, @trace).

§vis: Visibility

Visibility of this function definition.

Implementations§

Source§

impl MirFunction

Source

pub fn build_cfg(&mut self)

Build the CFG representation from the tree-form body. Stores the result in cfg_body.

Source

pub fn cfg(&mut self) -> &MirCfg

Return a reference to the CFG body, building it on demand if needed.

Subsequent calls reuse the cached CFG. Prefer build_cfg if you need to force a rebuild.

Trait Implementations§

Source§

impl Clone for MirFunction

Source§

fn clone(&self) -> MirFunction

Returns a duplicate 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.