-
-
Notifications
You must be signed in to change notification settings - Fork 14.4k
Closed
Description
Thy cyclic supertrait lint and super-trait tracing code should have an exception to allow for cyclic-safe traits.
https://play.rust-lang.org/?gist=cc794942ed0663d530d8&version=nightly
A trait definition like this is currently invalid.
trait Mode<M>: Mode<A> { type Return; }Instead of being invalid, this should cut the recursion at the point that M == RequiredMode.
Any type that implements Mode<B> must also implement Mode<A> and when selecting specific traits with <T as Trait>, the exact trait should be respected.
<T as Mode<B>>::Return // B
<T as Mode<A>>::Return // A
<<T as Mode<B>> as Mode<A>>::Return // AAs demonstrated in #12511, I would also say that trait T: T {} should be the identity of T, and consequently be the identity of the exception to permit cyclic-safe types.
Cyclic safe traits
trait Trait: Trait { ... } // Trait == Trait, stop recurring // lint redundant trait?trait Mode<M>: Mode<A> { ... } // When M == A, stop recurringCyclic unsafe traits
trait A: B { ... }
trait B: A { ... } Metadata
Metadata
Assignees
Labels
No labels