Skip to content

model deferred borrows for nested method calls #3

@nikomatsakis

Description

@nikomatsakis

I think my preference would be to extend the & operator with a defer "attribute:"

x = #[defer] &foo;

As a pre-pass to the processing, we would compute the "deferred region" R_D by looking for the next use of x. The 'loans in scope' would then create two loan entries, one for the main loan, and one for the same point that is deferred. We would give the deferred loan the region R_D; the main loans would be generated at the first-uses (i.e., as we exit the region R_D).

We then have to modify also the pass which checks that each action is legal: in particular, issuing a loan when there is a deferred region in scope is only legal if the lifetime of the loan is a subset of the deferred region R_D.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions