Mir: refactor how scopes are represented #29768
Labels
A-MIR
Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html
C-cleanup
Category: PRs that clean code up or issues documenting cleanup.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
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.
The text was updated successfully, but these errors were encountered: