-
Notifications
You must be signed in to change notification settings - Fork 73
Description
Proposal
Now that we have an impl for rust-lang/rust#144361, we can both downcast to types (we always could do that), and downcast to dyn Trait
objects. This means we can share logic between many types by having them implement the helper trait without needing that trait to be implemented for all types.
Just like downcasting to types, all of this is trivially optimizable by LLVM (it sees a None
constant for types that do not implement the trait), so I do not forsee even any compilation time regressions.
If there are indeed no practical issues like runtime perf regressions or compile-time perf regressions, I would like to apply this to as many uses of specialization as possible.
One major issue with the current scheme is that it doesn't fully work in const contexts, as we cannot call methods on the downcasted traits. Many specialization schemes do not rely on this however, they just use marker traits to decide whether to use a different code path.
Mentors or Reviewers
Process
The main points of the Major Change Process are as follows:
- File an issue describing the proposal.
- A compiler team member who is knowledgeable in the area can second by writing
@rustbot second
or kickoff a team FCP with@rfcbot fcp $RESOLUTION
.- Refer to Proposals, Approvals and Stabilization docs for when a second is sufficient, or when a full team FCP is required.
- Once an MCP is seconded, the Final Comment Period begins.
- Final Comment Period lasts for 10 days after all outstanding concerns are solved.
- Outstanding concerns will block the Final Comment Period from finishing. Once all concerns are resolved, the 10 day countdown is restarted.
- If no concerns are raised after 10 days since the resolution of the last outstanding concern, the MCP is considered approved.
You can read more about Major Change Proposals on forge.