I have 3 crates.
trait-defwith a trait definition :pub trait Test { type Exec; }underwith a first implementation of the trait for a type
pub struct First; pub struct FirstArgument; impl Test for First { type Exec = FirstArgument; } overwith a second implementation of the trait for another type
pub struct Second; pub struct SecondArgument; impl Test for Second { type Exec = SecondArgument; } Until here, everything is alright. However, when trying to implement a simple From, things go sideways :
impl From<<First as Test>::Exec> for SecondArgument { fn from(value: <First as Test>::Exec) -> Self { Self } } It says :
error[E0119]: conflicting implementations of trait `std::convert::From<SecondArgument>` for type `SecondArgument` | 13 | impl From<<First as Test>::Exec> for SecondArgument { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: conflicting implementation in crate `core`: - impl<T> std::convert::From<T> for T; This is a very simplified example and I can't just implement From<FirstArgument> for SecondArgument for unrelated reasons.
I know you have to be careful about implementations of From with traits, but here everything is set in stone, I'm not using generic types. Does someone have an answer as to why this is not accepted in Rust ? Thank you !
Edit : I have this repo that illustrates the situation (https://github.com/Kayanski/rust-trait-impl-reproduce)
The over crate reproduces the issue. The both crate which show having everything in the same crate doesn't reproduce the issue.