Closed
Description
Consider the following example.
Crate A
pub trait To<T> {
fn convert_to(&self) -> T;
}
pub trait Into<T>: Sized {
fn convert_into(self) -> T;
}
pub trait From<T> {
fn from(T) -> Self;
}
impl<'a, T: ?Sized, U> Into<U> for &'a T where T: To<U> {
fn convert_into(self) -> U {
self.convert_to()
}
}
impl<T, U> From<T> for U where T: Into<U> {
fn from(t: T) -> U {
t.convert_into()
}
}
Crate B
struct LocalType<T>(Option<T>);
impl<'a, T> From<&'a [T]> for LocalType<T> {
fn from(_: &'a [T]) -> LocalType<T> { LocalType(None) }
}
impl<T> Into<LocalType<T>> for LocalType<T> {
fn convert_into(self) -> LocalType<T> {
self
}
}
impl To<LocalType<u8>> for [u8] {
fn convert_to(&self) -> LocalType<u8> {
LocalType(None)
}
}
You get an error like:
conv-downstream.rs:6:1: 8:2 error: conflicting implementations for trait `conv_crate::From` [E0119]
conv-downstream.rs:6 impl<'a, T> From<&'a [T]> for LocalType<T> {
conv-downstream.rs:7 fn from(_: &'a [T]) -> LocalType<T> { LocalType(None) }
conv-downstream.rs:8 }
conv-downstream.rs:6:1: 8:2 note: conflicting implementation in crate `conv_crate`
conv-downstream.rs:6 impl<'a, T> From<&'a [T]> for LocalType<T> {
conv-downstream.rs:7 fn from(_: &'a [T]) -> LocalType<T> { LocalType(None) }
conv-downstream.rs:8 }
where the conflicting impls are identical ones, both drawn from the downstream crate.