Closed
Description
Proposal
Summary and problem statement
- Add the
trait_upcasting
feature to the language.
Motivation, use-cases, and solution sketches
- The
trait_upcasting
feature adds support for trait upcasting coercion. This allows a
trait object of typedyn Bar
to be cast to a trait object of typedyn Foo
so long asBar: Foo
.
#![feature(trait_upcasting)]
trait Foo {}
trait Bar: Foo {}
impl Foo for i32 {}
impl<T: Foo + ?Sized> Bar for T {}
let foo: &dyn Foo = &123;
let bar: &dyn Bar = foo;
Prioritization
- This belongs to the "Trait and type system extensions" part of the lang team priorities.
Links and related work
- Previously established tracking issue: Tracking issue for dyn upcasting coercion rust#65991
Initial people involved
Also cc @alexreg and @eddyb in case they're interested.
What happens now?
This issue is part of the experimental MCP process described in RFC 2936. Once this issue is filed, a Zulip topic will be opened for discussion, and the lang-team will review open MCPs in its weekly triage meetings. You should receive feedback within a week or two.
This issue is not meant to be used for technical discussion. There is a Zulip stream for that. Use this issue to leave procedural comments, such as volunteering to review, indicating that you second the proposal (or third, etc), or raising a concern that you would like to be addressed.