Error implementing From<T::Foo> for a generic type

The following produces a "conflicting implementations" error. Is there any reason it should or is this a bug?

impl<T> std::convert::From<<T as Foo>::Bar> for Error<T>
    T: Foo,
    fn from(e: <T as Foo>::Bar) -> Error<T> {
trait Foo {
    type Bar;
enum Error<T> where T: Foo {

Looks like it conflicts with the impl of From<T> for T from std, because as far as the compiler knows, <T as Foo>::Bar could be Error<T> itself.

Hmm... I guess that would technically be impossible, because then Error<T> would be an unconditionally recursive type (trying it got me the error overflow evaluating the requirement `Error<K>: std::marker::Sized` ). But I don't think the compiler includes that as part of its reasoning about conflicting impls.

Ah! I didn't think about it being possible to set the associated type to be the same as the impementing type. Thx!

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.