More conflicting implementation problems

I'm again struggling with a conflicting implementation issue.

Using the IndependentSample trait from the rand crate, I have the following code:

pub trait SimpleSample { ... }

impl<T> SimpleSample for T where T: IndependentSample<f64> { ... }

impl SimpleSample for u32 { ... }

The compilation error is:

error[E0119]: conflicting implementations of trait `SimpleSample` for type `u32`:
15 | impl<T> SimpleSample for T where T: IndependentSample<f64> {
   | - first implementation here

22 | impl SimpleSample for u32 {
   | ^ conflicting implementation for `u32`

My understanding is that this second impl for u32 would only conflict if u32 : IndependentSample<f64>, which isn't the case. The docs for IndependentSample list several implementations, and none of them are for `u32. To prove this to myself I tried writing this small test function:

fn foo<T>(t: T) where T: IndependentSample<f64> {  }

and got the error:

the trait bound `u32: rand::distributions::IndependentSample<f64>` is not satisfied

So what am I missing? Why do I have a conflicting implementation?

Playground link with the full code


The error is present because the crate defining IndependentSample may start implementing it for u32 in the future. We do not want it to be a backwards incompatible change to implement a trait for a new type.

Ahh, i see, thanks! And because my SomeOtherTrait is defined within the same crate, so such problem exists. thanks for the explanation.