-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Normalize all opaque types when converting ParamEnv to Reveal::All #65989
Conversation
(rust_highfive has picked a reviewer for you, use r? to override) |
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.
Just some nits. :)
Nice PR!
@Centril I've addressed your comments. |
r? @eddyb for review or reassignment |
This is @rust-lang/wg-traits territory. |
Ping from triage: Thanks! |
Pinging again from triage: Thanks! |
I'm not qualified to review this. |
☔ The latest upstream changes (presumably #66908) made this pull request unmergeable. Please resolve the merge conflicts. |
6d6b5d5
to
33e196d
Compare
Will review -- sorry for radio silence |
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.
Yet another example of why it would be good to pursue an alternative normalization strategy, I suppose. I am curious though whether this has any performance impact. We may want to think about more aggressive caching.
@bors try |
Normalize all opaque types when converting ParamEnv to Reveal::All When we normalize a type using a ParamEnv with a reveal mode of RevealMode::All, we will normalize opaque types to their underlying types (e.g. `type MyOpaque = impl Foo` -> `StructThatImplsFoo`). However, the ParamEnv may still have predicates referring to the un-normalized opaque type (e.g. `<T as MyTrait<MyOpaque>>`). This can cause trait projection to fail, since a type containing normalized opaque types will not match up with the un-normalized type in the `ParamEnv`. To fix this, we now explicitly normalize all opaque types in caller_bounds of a `ParamEnv` when changing its mode to `RevealMode::All`. This ensures that all predicatse will refer to the underlying types of any opaque types involved, allowing them to be matched up properly during projection. To reflect the fact that normalization is occuring, `ParamEnv::with_reveal_all` is renamed to `ParamEnv::with_reveal_all_normalized` Fixes #65918
☀️ Try build successful - checks-azure |
@nikomatsakis: Did you mean to do a |
@Aaron1011 dang it, yes I did |
Queued 95dcfa37cf97c1d630a7820e31d39a7a37ae2c1d with parent 4825e12, future comparison URL. |
Finished benchmarking try commit (95dcfa37cf97c1d630a7820e31d39a7a37ae2c1d): comparison url. Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. Please note that if the perf results are neutral, you should likely undo the rollup=never given below by specifying Importantly, though, if the results of this run are non-neutral do not roll this PR up -- it will mask other regressions or improvements in the roll up. @bors rollup=never |
@nikomatsakis: It looks like almost all of the perf impact is gone. |
@bors r+ |
📌 Commit 5e2e927 has been approved by |
⌛ Testing commit 5e2e927 with merge a7b1b8ea5d0b7b7e6d162fe0066eb0f1afc94778... |
💔 Test failed - checks-actions |
I think this was a spurious failure. @bors r=nikomatsakis |
💡 This pull request was already approved, no need to approve it again.
|
📌 Commit 5e2e927 has been approved by |
☀️ Test successful - checks-actions, checks-azure |
This was a slight performance regression, as expected. |
This test was fixed by rust-lang#65989
When we normalize a type using a ParamEnv with a reveal mode of
RevealMode::All, we will normalize opaque types to their underlying
types (e.g.
type MyOpaque = impl Foo
->StructThatImplsFoo
).However, the ParamEnv may still have predicates referring to the
un-normalized opaque type (e.g.
<T as MyTrait<MyOpaque>>
). This cancause trait projection to fail, since a type containing normalized
opaque types will not match up with the un-normalized type in the
ParamEnv
.To fix this, we now explicitly normalize all opaque types in
caller_bounds of a
ParamEnv
when changing its mode toRevealMode::All
. This ensures that all predicatse will refer to theunderlying types of any opaque types involved, allowing them to be
matched up properly during projection. To reflect the fact that
normalization is occuring,
ParamEnv::with_reveal_all
is renamed toParamEnv::with_reveal_all_normalized
Fixes #65918