Module rustc_ast_lowering::delegation

source ·
Expand description

This module implements expansion of delegation items with early resolved paths. It includes a delegation to a free functions:

reuse module::name { target_expr_template }

And delegation to a trait methods:

reuse <Type as Trait>::name { target_expr_template }

After expansion for both cases we get:

fn name(
    arg0: InferDelegation(sig_id, Input(0)),
    arg1: InferDelegation(sig_id, Input(1)),
    ...,
    argN: InferDelegation(sig_id, Input(N)),
) -> InferDelegation(sig_id, Output) {
    callee_path(target_expr_template(arg0), arg1, ..., argN)
}

Where callee_path is a path in delegation item e.g. <Type as Trait>::name. sig_id is a id of item from which the signature is inherited. It may be a delegation item id (item_id) in case of impl trait or path resolution id (path_id) otherwise.

Since we do not have a proper way to obtain function type information by path resolution in AST, we mark each function parameter type as InferDelegation and inherit it during HIR ty lowering.

Similarly generics, predicates and header are set to the “default” values. In case of discrepancy with callee function the UnsupportedDelegation error will also be emitted during HIR ty lowering.

Structs§