-
Notifications
You must be signed in to change notification settings - Fork 13k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Track closure signatures & kinds in freshened types #43938
Conversation
src/librustc/infer/freshen.rs
Outdated
.chain([closure_sig_marker, closure_kind_marker].iter().cloned() | ||
.map(From::from)) | ||
.collect(); | ||
let params = tcx.intern_substs(¶ms); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be possible to call mk_substs
on the iterator here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I get the idea here -- this is clever. The other approach that I had been contemplating was slightly different. I had hoped to add facts to the environment indicating when we know the kind of a closure (rather than invoking closure_kind
, basically). In this way, we would invalidate the cached entries because there would be a new environment. But I think this is a simpler thing to do for now for sure (and maybe forever -- since I was worried about screwing up the caching results of other things if we grow the param env).
@@ -150,6 +157,53 @@ impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for TypeFreshener<'a, 'gcx, 'tcx> { | |||
t | |||
} | |||
|
|||
ty::TyClosure(def_id, substs) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
feels like some comments laying out the strategy here would be very welcome
After a projection was processed, its derived subobligations no longer need any processing when encountered, and can be removed. This improves the status of rust-lang#43787. This is actually complementary to rust-lang#43938 - that PR fixes selection caching (and @remram44's example, which "accidentally" worked because of the buggy projection caching) while this PR fixes projection caching
Now with cleaner code & comments & hopefully ready for landing! |
NOTE: this PR will require some changes after #43076 lands, so I'll have this (unchanged) version for beta and a modified version for master. |
☔ The latest upstream changes (presumably #43076) made this pull request unmergeable. Please resolve the merge conflicts. |
clear out projection subobligations after they are processed After a projection was processed, its derived subobligations no longer need any processing when encountered, and can be removed. This improves the status of #43787. This is actually complementary to #43938 - that PR fixes selection caching (and @remram44's example, which "accidentally" worked because of the buggy projection caching) while this PR fixes projection caching. r? @nikomatsakis
This allows caching closure signatures and kinds in the normal selection and evaluation caches, and fixes the exponential worst-case in @remram44's example, which is a part of rust-lang#43787. This improvement is complenentary to rust-lang#43999 - they fix different cases.
Rebased |
//! comparisons (for caching), it is possible to do a `ty::_match` operation between | ||
//! 2 freshened types - this works even with the closure encoding. | ||
//! | ||
//! __An important detail concerning regions.__ The freshener also replaces *all* free regions with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice comments
@bors r+ |
📌 Commit 75d6820 has been approved by |
⌛ Testing commit 75d6820 with merge 2edfd62c37290bd1a24da88a4aee315ed4c1cfdf... |
💔 Test failed - status-travis |
@bors retry |
Please don't roll this up as this is a performance improvement PR. |
@bors p=100 |
Track closure signatures & kinds in freshened types r? @nikomatsakis
☀️ Test successful - status-appveyor, status-travis |
[beta] Track closure signatures & kinds in freshened types This allows caching closure signatures and kinds in the normal selection and evaluation caches, and fixes the exponential worst-case in @remram44's example, which is a part of #43787. This improvement is complenentary to #43999 - they fix different cases. This is the pre-generators variation of #43938, cloned for beta.
After a projection was processed, its derived subobligations no longer need any processing when encountered, and can be removed. This improves the status of rust-lang#43787. This is actually complementary to rust-lang#43938 - that PR fixes selection caching (and @remram44's example, which "accidentally" worked because of the buggy projection caching) while this PR fixes projection caching
r? @nikomatsakis