Skip to content

rustc: simpler ParameterEnvironment and free regions. - #41914

Merged
bors merged 10 commits into
rust-lang:masterfrom
eddyb:region-refactor
May 13, 2017
Merged

rustc: simpler ParameterEnvironment and free regions.#41914
bors merged 10 commits into
rust-lang:masterfrom
eddyb:region-refactor

Conversation

@eddyb

Copy link
Copy Markdown
Contributor

The commits describe the slow transformation but the highlights are:

  • ReEarlyBound is considered free, with a scope based on the item that defined the lifetime parameter, and the root body of the RegionMaps in use, removing the need for free_substs
  • liberate_late_bound_regions and implicit_region_bound moved to typeck
  • CodeExtent not interned at all now - ideally it would be 2 u32 but it's small anyway

Future work building up on this could include:

  • ParameterEnvironment becoming just the result of predicates_of
    • interning makes my "parent chain" scheme unnecessary
  • implicit_region_bound could be retrieved from RegionMaps
  • renaming CodeExtent to Scope
    • generalizing "call site" to "use site" or something better to include constants
  • renaming RegionMaps to ScopeTree and its API to talk about "parents" explicitly

@rust-highfive

Copy link
Copy Markdown
Contributor

r? @pnkfelix

(rust_highfive has picked a reviewer for you, use r? to override)

@nikomatsakis

Copy link
Copy Markdown
Contributor

r? @nikomatsakis

@nikomatsakisnikomatsakis left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, this looks pretty nice. I left two small nits.

Comment threadsrc/librustc/middle/region.rs Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't really follow what's going on here; maybe add a comment or two for what kinds of rust code falls into which case here?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is explained on root_parent but do note this is not the final version of that function.
Let me know on the final functions where it seems unclear.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe combine these by changing the type to RefCell<FxHashSet<(ty::Region<'tcx>, ty::RegionVid)>>, where the region is either an early-bound or free?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was wondering if that would be more expensive but I doubt it now. Will do.

@nikomatsakis

Copy link
Copy Markdown
Contributor

I see that the librustc_driver unit tests are failing. I do hate those. I've been wanting to refactor them in such a way that we can encode the same scenarios in .rs files, but it's kind of difficult. I'm tempted to just tell you to delete them -- I'm not sure to what extent we have complete coverage of those scenarios elsewhere though (specifically some of the LUB tests).

@arielb1

Copy link
Copy Markdown
Contributor

CodeExtent was interned as a u32 once upon a time. Not sure why that changed.

Comment threadsrc/librustc/middle/region.rs Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why can't you use fr.scope directly?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted to have no regressions from lifetime parameters not defined on the scope leaking into e.g. the signature of a closure.

@nikomatsakis

Copy link
Copy Markdown
Contributor

@arielb1

CodeExtent was interned as a u32 once upon a time. Not sure why that changed.

I changed that to a pointer because there were various contexts that needed to be able to access the data without having enough context to get a region-maps (note that there is now more than one region-maps). But passing by value is probably even better. (Also, in the meantime, we've started to intern Regions, so I don't think that the size matters so much anymore anyway.)

@alexcrichtonalexcrichton added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 11, 2017
Comment threadsrc/librustc/middle/region.rs Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 nice comment

@nikomatsakis

Copy link
Copy Markdown
Contributor

@bors r+

@bors

bors commented May 12, 2017

Copy link
Copy Markdown
Collaborator

📌 Commit 788e70e has been approved by nikomatsakis

bors added a commit that referenced this pull request May 12, 2017
@bors

bors commented May 13, 2017

Copy link
Copy Markdown
Collaborator

☔ The latest upstream changes (presumably #41965) made this pull request unmergeable. Please resolve the merge conflicts.

@eddyb

Copy link
Copy Markdown
ContributorAuthor

@bors r=nikomatsakis

@bors

bors commented May 13, 2017

Copy link
Copy Markdown
Collaborator

📌 Commit 6da4123 has been approved by nikomatsakis

@eddyb

Copy link
Copy Markdown
ContributorAuthor

@bors p=1000 (separate for perf. I wish we had a guaranteed to keep PRs out of rollups)

@bors

bors commented May 13, 2017

Copy link
Copy Markdown
Collaborator

⌛ Testing commit 6da4123 with merge 826d8f3...

bors added a commit that referenced this pull request May 13, 2017
rustc: simpler ParameterEnvironment and free regions.
The commits describe the slow transformation but the highlights are:
* `ReEarlyBound` is considered free, with a scope based on the item that defined the lifetime parameter, and the root body of the `RegionMaps` in use, removing the need for `free_substs`
* `liberate_late_bound_regions` and `implicit_region_bound` moved to typeck
* `CodeExtent` not interned at all now - ideally it would be 2 `u32` but it's small anyway
Future work building up on this could include:
* `ParameterEnvironment` becoming just the result of `predicates_of`
* interning makes my "parent chain" scheme unnecessary
* `implicit_region_bound` could be retrieved from `RegionMaps`
* renaming `CodeExtent` to `Scope`
* generalizing "call site" to "use site" or something better to include constants
* renaming `RegionMaps` to `ScopeTree` and its API to talk about "parents" explicitly
@bors

bors commented May 13, 2017

Copy link
Copy Markdown
Collaborator

☀️ Test successful - status-appveyor, status-travis
Approved by: nikomatsakis
Pushing 826d8f3 to master...

@bors
bors merged commit 6da4123 into rust-lang:masterMay 13, 2017
@eddyb
eddyb deleted the region-refactor branch May 14, 2017 02:58
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-reviewStatus: Awaiting review from the assignee but also interested parties.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants

@eddyb@rust-highfive@nikomatsakis@arielb1@bors@alexcrichton@pnkfelix