Traits: Roadmap sketch

Idea stage
  • associated traits, quantification over traits
  • gadts (where clauses on enum variants)
  • Trait object improvements
  • AsRef inference limitations — some way to avoid the “every time I add an impl, code breaks” problem (probably opt-in, tied to the edition)

Pre-RFC stage
  • HRTB for types
  • Centril has been working on this
  • Related to generic closures, but the latter is an important part of the motivation here
  • Fields in traits

RFC stage
  • Delegation
  • Hasn’t seen much movement; mostly language team’s fault!
  • trickiest bits: interactions with Drop, interactions with provided methods
  • Some weirdness with specialization (unsound in one model, to fix unsoundness the interaction with specialization becomes weird)

Implementation stage
  • GATs
  • Implied bounds
  • Trait aliases (needs more design)
  • Existential types (centril working on fcp)
  • Associated type defaults
  • Specialization
  • Needs spec-level rework, possibly additional RFC
  • Associated type bound syntax improvements
  • Needs tests
  • Inherent associated types
  • Re-re-balancing coherence


Named existential types

  • There are probably implementation issue aside from syntax changes (which will need implementation changes).

let foo: impl Bar; / Impl Trait in Bindings

#![feature(impl_trait_in_bindings)]
fn foo() {
    let x: impl core::fmt::Debug = 12;
    static x: impl core::fmt::Debug = 12;
    const x: impl core::fmt::Debug = 12;