-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Stablize trait_upcasting
feature
#101718
Stablize trait_upcasting
feature
#101718
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
1f0111b
to
81b4025
Compare
Note: FCP for unblocking upcasts at #101336. |
Stabilization reportThis PR proposes the stablization of the We are stablizing a new kind of coercion, which is "upcasts" from a trait Foo {
fn foo_method(&self);
}
trait Bar: Foo {
fn bar_method(&self);
}
let x: &dyn Bar = /* ... */;
let y: &dyn Foo = x; // compiles The key factor for these upcasts is that they require adjusting the vtable. The current implementation strategy is that the vtables for the
This way, given a For some examples of code patterns that this feature enables, see Integration with |
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
@rfcbot fcp merge Now that the FCP in #101336 has ended, I'm going to move to stabilize dyn upcasting. @crlf0710 has provided a stabilization report here. |
Team member @nikomatsakis has proposed to merge this. The next step is review by the rest of the tagged team members: Concerns:
Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
@rfcbot concern doc-pr I believe we need a PR against the reference describing when upcasts are allowed (it doesn't, I think, have to document the vtable layout or anything like that). I'm not sure if the reference also talks at all about validity/unsafety invariants, though. |
@rustbot label +I-types-nominated I'm nominating this for @rust-lang/types visibility, however, to make sure we feel comfortable with this being stabilized from a type system perspective. It is implemented by extending the existing ability to "upcast" a |
The Reference PR is at rust-lang/reference#1259, though admittedly the descriptions are pretty brief, only covered the major points... Let me know if the text needs any expansion :) |
@rfcbot concern rfc This has been the subject of a great deal of discussion and iteration, and I really do think this should have an RFC before stabilization. I've been expecting that it would get an RFC. |
@nikomatsakis proposal cancelled. |
I think we should keep the reference PR open, but add a note. |
…affleLapkin Stabilize RFC3324 dyn upcasting coercion This PR stabilize the `trait_upcasting` feature, aka rust-lang/rfcs#3324. The FCP was completed here: rust-lang#65991 (comment). ~~And also remove the `deref_into_dyn_supertrait` lint which is now handled by dyn upcasting coercion.~~ Heavily inspired by rust-lang#101718 Fixes rust-lang#65991
…affleLapkin Stabilize RFC3324 dyn upcasting coercion This PR stabilize the `trait_upcasting` feature, aka rust-lang/rfcs#3324. The FCP was completed here: rust-lang#65991 (comment). ~~And also remove the `deref_into_dyn_supertrait` lint which is now handled by dyn upcasting coercion.~~ Heavily inspired by rust-lang#101718 Fixes rust-lang#65991
Stabilize RFC3324 dyn upcasting coercion This PR stabilize the `trait_upcasting` feature, aka rust-lang/rfcs#3324. The FCP was completed here: rust-lang/rust#65991 (comment). ~~And also remove the `deref_into_dyn_supertrait` lint which is now handled by dyn upcasting coercion.~~ Heavily inspired by rust-lang/rust#101718 Fixes rust-lang/rust#65991
Closes #65991.
Closes #89460.