Trait Solver 5 @BoxyUwU @WaffleLapkin @lcnr
Warning: this quiz is still "work-in-progress", some questions might not have good explanations (or any at all), formatting/structure/titles/etc are not final, and so on. You might want to return here on a later date.
pub trait Super {}
pub trait Sub<T>: Super {}
pub trait Overlap<T> {}
impl<T, U: Sub<T>> Overlap<T> for U {}
impl<T> Overlap<T> for () {}
fn main() {}
Solution
In order for these impls to overlap the type ()
must implement Sub<T>
for some type T
, the Sub
trait is public so in theory some downstream crate could implement (): Sub<Local>
. However, the supertrait Super
cannot be implement for the type ()
by any downstream crates as impl Super for () {
would not pass the orphan check in downstream crates
If we were to introduce an impl Super for () {
to this example then coherence would forbid this code.