Skip to content

rustc wrongly reports conflicting trait implementations #31115

Closed
@rphmeier

Description

@rphmeier
use std::marker::PhantomData;

trait Foo {
    type Bar: Interface<Self>; // = Default<Self>
}

trait Interface<T: Foo> {}

// default implementation, we never implement Alternate<T> for this.
trait DefaultFoo: Foo<Bar=Default<Self>> {}
struct Default<T: DefaultFoo> {
    _marker: PhantomData<T>,
}
impl<T: DefaultFoo> Interface<T> for Default<T> {}

// alternate implementations must use this trait
// predicate on A: Alternate<T> should preclude Default<T>.
trait Alternate<T: Foo<Bar=Self>> {}
impl<T, A> Interface<T> for A
where T: Foo<Bar=A>, A: Alternate<T> {}

fn main() {}

fails with E0119, although the Self types don't overlap.
Playpen: http://is.gd/vT98nf, fails on Stable, Beta, and Nightly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    T-langRelevant to the language team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions