Skip to main content

push_capture_scope

Function push_capture_scope 

Source
pub fn push_capture_scope(
    v: &mut Vec<Variable>,
    captures: &[(SmolStr, DataType, Option<DataType>)],
)
Expand description

Infers the return type of a user function specialised for infered_arg_types, caching the result on the function.

Shared by direct FunctionCalls and by impl method calls (which resolve to a mangled free function with the receiver as argument 0). function_name is only used for diagnostics inside track_returns.

type_args are the arguments a generic call named. They are part of the specialisation key because a type parameter no argument mentions still changes what the body builds. Declares a closure’s captures in v, ahead of its parameters, which shadow a capture of the same name. A closure body reads what the closure captured, so those names are in scope both while its return type is worked out and while its body compiles.