Skip to content

Mir: refactor how scopes are represented #29768

Closed
@nikomatsakis

Description

@nikomatsakis

Mir currently tracks scopes using these graph extents. These are a pain. They are hard to keep in sync, for one thing, as we transform the MIR. I now think we should instead store, for each statement, the innermost scope. This will allow us to recover the full set of scopes for debuginfo, as well as computing whether a statement is in an unsafe block or what.

However, for borrowck, we also need to have scopes be grouped into continuous regions of the control-flow-graph, and we need to know as we exit a scope. For this purpose, the graph extents are tolerably good, or it seems useful to have a "SCOPE-ENTRY" and "SCOPE-EXIT" sort of statement. We might just do the borrowck before we do any optimization.

In a non-lexical lifetimes world, though, introducing SCOPE-ENTRY and SCOPE-EXIT statements for all regions would be horrible and a pain. So it seems better that we keep the notion of graph extents for the purposes of borrowck, and we just avoid changing the structure between computing graph extents and running borrowck -- or else we keep the graph extents up to date.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-MIRArea: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.htmlC-cleanupCategory: PRs that clean code up or issues documenting cleanup.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions