Associated item projections across crate boundaries slightly broken
pub trait Foo<T> { }
pub trait Mirror {
type Dual;
}
pub struct Eps;
pub struct A<T, U>(T, U);
impl<T, U: Mirror> Mirror for A<T, U> { type Dual = B<T, U::Dual>; }
pub struct B<T, U>(T, U);
impl<T, U: Mirror> Mirror for B<T, U> { type Dual = A<T, U::Dual>; }
impl Mirror for Eps { type Dual = Eps; }
extern crate whatever;
use whatever::*;
struct Dummy;
impl Foo<A<Eps, B<Eps, Eps>>> for Dummy {}
// doesn't work, causes "conflicting implementations for trait `whatever::Foo`"
// impl Foo<<A<Eps, B<Eps, Eps>> as Mirror>::Dual> for Dummy {}
// works just fine
// impl Foo<B<Eps, A<Eps, Eps>>> for Dummy {}
This despite the fact that <A<Eps, B<Eps, Eps>> as Mirror>::Dual and B<Eps, A<Eps, Eps>> are the same type. It works just fine when they're in the same crate.
pub trait Foo<T> { } pub trait Mirror { type Dual; } pub struct Eps; pub struct A<T, U>(T, U); impl<T, U: Mirror> Mirror for A<T, U> { type Dual = B<T, U::Dual>; } pub struct B<T, U>(T, U); impl<T, U: Mirror> Mirror for B<T, U> { type Dual = A<T, U::Dual>; } impl Mirror for Eps { type Dual = Eps; }extern crate whatever; use whatever::*; struct Dummy; impl Foo<A<Eps, B<Eps, Eps>>> for Dummy {} // doesn't work, causes "conflicting implementations for trait `whatever::Foo`" // impl Foo<<A<Eps, B<Eps, Eps>> as Mirror>::Dual> for Dummy {} // works just fine // impl Foo<B<Eps, A<Eps, Eps>>> for Dummy {}This despite the fact that
<A<Eps, B<Eps, Eps>> as Mirror>::DualandB<Eps, A<Eps, Eps>>are the same type. It works just fine when they're in the same crate.León Orell Valerian Liehr at 2024-09-03 08:55:39
Needs repro.
Brian Anderson at 2017-03-23 16:53:39
Is this a bug? P-?
Brian Anderson at 2017-03-23 16:54:09
I agree this is a bug. I think it falls under the general category of "failure to normalize" that I expect to basically go away as part of the "chalk overhaul" (https://github.com/rust-lang/rust-roadmap/issues/8).
Niko Matsakis at 2017-04-28 20:55:14
triage: P-medium
Niko Matsakis at 2017-04-28 20:55:25
This bug report is still correct with rustc 1.44.1. I am commenting because the contribution guidelines say it is helpful to check whether old bug reports are still correct.
Valentin at 2020-06-19 10:29:31