Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Library Trait Evolution Experiment

Metadata
Point of contactlcnr
What and whyEnable library authors to more easily change their trait definitions
StatusProposed
Tracking issuerust-lang/rust-project-goals#712
Zulip channelN/A
lang championTyler Mandry
types championlcnr
Funding contactHexcat
Teamslang, libs, types
Task ownerslcnr

Summary

Setup a Library Trait Evolution experiment. It works to unify the design of language features to make trait definitions less rigid. This includes refined trait implementations and Supertrait Auto-impl, but also more targeted features for the standard library, such as #[rustc_must_implement_one_of].

We plan to collect different use-cases and requirements here, both from the standard library and the wider ecosystem. We then use this to design, implement, and stabilize features solving these issues.

Motivation

The status quo

Trait evolution and trait hierarchy refactoring is a long-time pain point for Rust crates and especially the standard library. As crates evolve and grow, needs to restructure trait hierarchy to accommodate richer functionality often arises, both in the standard library and the broader Rust ecosystem.

This will be even more of an issue once we add new implicit default auto trait bounds to support Immobile types and guaranteed destructors or the Sized Hierarchy. For example in trait Trait { fn foo<T>(); } the generic parameter T will get an implicit T: Move bound whose removal is a breaking change. This makes immobile types a lot less useable with existing traits.

Work items over the next year

TaskOwner(s)Notes
Setup a Library Trait Evolution experiment and create its repositorylcnr
Collect and explore different use-cases in a single repositorylcnr
Collaborate on the design and implementation of language features to solve these issueslcnr

Team asks

TeamSupport levelNotes
langMediumProbably want to have a lang meeting at some point
libsSmallWe would like to test some of the desired standard library changes and get input on the design
typesMediumReview and discuss type system changes if required

Funding

PurposeCostFundedSponsor(s)
ContributorAskPartial

Frequently asked questions