Skip to content

[NLL] store a value for each region #44870

Closed
@nikomatsakis

Description

@nikomatsakis

The NLL code currently contains code to renumber all regions into fresh region variables, but it contains no map storing the value of those region variables.

We should define a struct Region that will store the value of a non-lexical region. This struct would resemble Region from the NLL prototype and basically play the same role. I think it can initially look something like this:

#[derive(Clone, Debug, Default, Hash, PartialEq, Eq)]
struct Region {
    points: FxHashSet<Location>,
}

The Location struct is defined in librustc/mir and it is basically a "point" -- basic block + statement index.

Then we should add to the NLLVisitor struct a field like region_values: Vec<Region>. Each time that we create a new region variable, we will also push a Region::default() onto the vector to serve as its (initially empty) value.

Eventually, this struct will also want to contain free regions. but I figure we can start without them, while we debate how best to represent free regions here. (Probably ty::Region<'tcx> for now, but I think we can ignore it for now and just target "intra-function" cases.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.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