Skip to main content

generated_function_path

Function generated_function_path 

Source
pub fn generated_function_path<'db>(
    db: &'db dyn Database,
    node: SyntaxNode<'db>,
) -> impl Display + 'db
Expand description

Returns the path of the generated function created for node - or for its closest ancestor that is lowered into a generated function - relative to the function it is defined in.

Every level of nesting adds a {<kind>#<index>} segment, where the index counts, per kind, the generated functions directly within the enclosing generated function (or within the function itself). So the closures of:

ⓘ
fn foo() {
    let outer = |x| {
        let inner = |y| y;
        inner(x)
    };
    let last = |z| z;
}

are {closure#0}, {closure#0}::{closure#0} and {closure#1}.

As the path only depends on the code of the containing function, it makes the names of generated functions independent of the path of the file they are defined in, and of any code outside of their containing function.