-
Notifications
You must be signed in to change notification settings - Fork 13.3k
fix trait objects with a Self-containing projection values #56863
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Conversation
This follows ALT2 in the issue. Fixes rust-lang#56288.
cc #56865 |
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.
Left some comments for the tests, but this seems reasonable.
One thing I found myself wondering:
What will happen if you have
trait Helper: Base<Output = <Self as Helper>::Target> + Base<Output = u32> { ... }
maybe worth testing that? I'm kind of "OK" with any outcome =) My expectation is that dyn Helper
will not require Output
to be specified based on the code though, but I could easily be missing something.
r=me with nits addressed + new test
@@ -0,0 +1,22 @@ | |||
trait Base { |
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.
Let's add a comment to this test:
Regression test for #56288. Checks that if a supertrait defines an associated type projection that references Self
, then that associated type must still be explicitly specified in the dyn Trait
variant, since we don't know what Self
is anymore.
@@ -0,0 +1,23 @@ | |||
// compile-pass |
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.
Similarly a comment here would be good:
Regression test related to #56288. Check that a supertrait projection (of Output
) that references Self
can be ok if it is referencing a projection (of Self::Target
, in this case). Note that we still require the user to manually specify both Target
and Output
for now.
In that case, you will get an E0282 while WF-checking the trait (even if it is not used anywhere), unless rustc manages to normalize the projection and finds that it is equal to Actually, I did manage to get a test to work. Will add that. |
Done. |
@bors r+ |
📌 Commit 1fd23f5 has been approved by |
@bors p=1 -- regression fix |
fix trait objects with a Self-containing projection values Fixes #56288. This follows ALT2 in the issue. beta-nominating since this is a regression. r? @nikomatsakis
☀️ Test successful - status-appveyor, status-travis |
discussed at T-compiler meeting. beta-accepting. |
Fixes #56288.
This follows ALT2 in the issue.
beta-nominating since this is a regression.
r? @nikomatsakis