rustc: simpler ParameterEnvironment and free regions.#41914
rustc: simpler ParameterEnvironment and free regions.#41914bors merged 10 commits intorust-lang:masterfrom
Conversation
|
r? @pnkfelix (rust_highfive has picked a reviewer for you, use r? to override) |
nikomatsakis
left a comment
There was a problem hiding this comment.
OK, this looks pretty nice. I left two small nits.
src/librustc/middle/region.rs
Outdated
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
I was wondering if that would be more expensive but I doubt it now. Will do.
|
I see that the |
|
|
src/librustc/middle/region.rs
Outdated
There was a problem hiding this comment.
Why can't you use fr.scope directly?
There was a problem hiding this comment.
I wanted to have no regressions from lifetime parameters not defined on the scope leaking into e.g. the signature of a closure.
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.) |
src/librustc/middle/region.rs
Outdated
|
@bors r+ |
|
📌 Commit 788e70e has been approved by |
|
☔ The latest upstream changes (presumably #41965) made this pull request unmergeable. Please resolve the merge conflicts. |
|
@bors r=nikomatsakis |
|
📌 Commit 6da4123 has been approved by |
|
@bors p=1000 (separate for perf. I wish we had a guaranteed to keep PRs out of rollups) |
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
|
☀️ Test successful - status-appveyor, status-travis |
The commits describe the slow transformation but the highlights are:
ReEarlyBoundis considered free, with a scope based on the item that defined the lifetime parameter, and the root body of theRegionMapsin use, removing the need forfree_substsliberate_late_bound_regionsandimplicit_region_boundmoved to typeckCodeExtentnot interned at all now - ideally it would be 2u32but it's small anywayFuture work building up on this could include:
ParameterEnvironmentbecoming just the result ofpredicates_ofimplicit_region_boundcould be retrieved fromRegionMapsCodeExtenttoScopeRegionMapstoScopeTreeand its API to talk about "parents" explicitly