-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Regression: "no method found" error when calling same method twice, with HRTB impl #37154
Comments
In case it's useful to anyone, here's a EDIT: Here is the log with In particular, the first call causes this:
While the log contains 2 (not sure why not just one) occurrences of this (this logging statement was added by me, so don't go searching the logs from master), after the first call has been resolved:
Which then causes |
This, like #36325, was introduced between these two nightlies: Works on
Broken on
These regressions likely have the same cause. I suspect the projection cache, introduced in #33816. |
The projection cache indeed looks like it. |
So yes did a bit of digging and the projection cache is indeed doing some inappropriate caching here. I have a hacky fix; currently debating about a mildly less hacky one. Still not overly happy with how we handle skolemization today but that's another story. =) |
Pending PR: #37294 |
Thanks @nikomatsakis ! |
…sakis remove keys w/ skolemized regions from proj cache when popping skolemized regions This addresses rust-lang#37154 (a regression). The projection cache was incorrectly caching the results for skolemized regions -- when we pop skolemized regions, we are supposed to drop cache keys for them (just as we remove those skolemized regions from the region inference graph). This is because those skolemized region numbers will be reused later with different meaning (and we have determined that the old ones don't leak out in any meaningful way). I did a *somewhat* aggressive fix here of only removing keys that mention the skolemized regions. One could imagine just removing all keys added since we started the skolemization (as indeed I did in my initial commit). This more aggressive fix required fixing a latent bug in `TypeFlags`, as an aside. I believe the more aggressive fix is correct; clearly there can be entries that are unrelated to the skoelemized region, and it's a shame to remove them. My one concern was that it *is* possible I believe to have some region variables that are created and related to skolemized regions, and maybe some of them could end up in the cache. However, that seems harmless enough to me-- those relations will be removed, and couldn't have impacted how trait resolution proceeded anyway (iow, the cache entry is not wrong, though it is kind of useless). r? @pnkfelix cc @arielb1
remove keys w/ skolemized regions from proj cache when popping skolemized regions This addresses #37154 (a regression). The projection cache was incorrectly caching the results for skolemized regions -- when we pop skolemized regions, we are supposed to drop cache keys for them (just as we remove those skolemized regions from the region inference graph). This is because those skolemized region numbers will be reused later with different meaning (and we have determined that the old ones don't leak out in any meaningful way). I did a *somewhat* aggressive fix here of only removing keys that mention the skolemized regions. One could imagine just removing all keys added since we started the skolemization (as indeed I did in my initial commit). This more aggressive fix required fixing a latent bug in `TypeFlags`, as an aside. I believe the more aggressive fix is correct; clearly there can be entries that are unrelated to the skoelemized region, and it's a shame to remove them. My one concern was that it *is* possible I believe to have some region variables that are created and related to skolemized regions, and maybe some of them could end up in the cache. However, that seems harmless enough to me-- those relations will be removed, and couldn't have impacted how trait resolution proceeded anyway (iow, the cache entry is not wrong, though it is kind of useless). r? @pnkfelix cc @arielb1
The following code (playground link) results in a method resolution error on the second call to
x.method()
. It compiles successfully ifx.method()
is called only once:The error is:
@jonas-schievink suggested this might be a bug in the projection cache or some other cache.
This is a regression from Rust 1.10.0-stable to 1.11.0-stable.
The text was updated successfully, but these errors were encountered: