pub struct Function {
pub def_id: DefId,
pub name: String,
pub generics: u32,
pub bounds: Vec<Vec<DefId>>,
pub takes_env: bool,
pub capture_count: u32,
pub params: u32,
pub locals: Vec<Local>,
pub ret_ty: Ty,
pub is_async: bool,
pub body: Expr,
pub span: Span,
}Expand description
A typed function.
Fields§
§def_id: DefId§name: String§generics: u32Number of generic parameters; generic functions are monomorphized before codegen.
bounds: Vec<Vec<DefId>>Trait bounds per generic parameter (bounds[i] are the trait
DefIds the i-th parameter must satisfy). Checked at
monomorphization once the concrete type argument is known.
takes_env: boolWhether this function is the code of a function value (a closure or
a bare-fn wrapper). Such functions take a leading environment
pointer in their ABI: (env_ptr, params...). Normal, directly
called functions do not.
capture_count: u32For a closure, the number of leading locals that are captured
variables loaded from the environment at entry (0 for a bare-fn
wrapper). The captured locals precede the real parameters.
params: u32The first params entries of locals are the real parameters
(after any captures). For a closure the captured locals occupy
indices 0..capture_count and the parameters capture_count...
locals: Vec<Local>§ret_ty: Ty§is_async: boolWhether this function was declared async. ret_ty is already
Ty::Future(output) when true; this flag is what tells nova-mir
which functions to treat specially, since a non-async function may
also return a Future (by calling an async fn and not awaiting it),
so ret_ty alone can’t distinguish them — which is the whole reason
this flag exists rather than a test on ret_ty’s shape.
What nova-mir does with it is that crate’s contract
(nova-mir/src/async_lower.rs), not restated here, for the reason
ExprKind::Await’s doc gives.
body: Expr§span: Span