-
Notifications
You must be signed in to change notification settings - Fork 14.1k
Open
Labels
C-bugCategory: This is a bug.Category: This is a bug.needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.This issue may need triage. Remove it if it has been sufficiently triaged.
Description
I tried this code:
use std::ops::{Add, Mul};
pub struct Generic<A>(A);
impl<A, B> Mul<Generic<B>> for Generic<A>
where
A: Add<B>,
{
type Output = Generic<<A as Add<B>>::Output>;
fn mul(self, rhs: Generic<B>) -> Self::Output {
Generic(self.0.add(rhs.0))
}
}
type A = <Generic<i32> as Mul<Generic<i32>>>::Output;
type B = <Generic<u32> as Mul<Generic<u32>>>::Output;
trait Trait {}
impl Trait for A {}
impl Trait for B {}I expected to see this happen: code to compile.
Associated type Mul::Output should expand to different concrete types - Generic<i32> and Generic<u32>, and as such impls should be coherent.
Instead, this happened: compiler reports conflicting implementations of Trait
error[E0119]: conflicting implementations of trait `Trait` for type `<Generic<i32> as Mul>::Output`
--> src/mini.rs:23:1
|
21 | impl Trait for A {}
| ---------------- first implementation here
22 |
23 | impl Trait for B {}
| ^^^^^^^^^^^^^^^^ conflicting implementation for `<Generic<i32> as Mul>::Output`
I've looked for similar bug reports, most similar one I've found was #99940. Discussion there however takes place in the context of intercrate interactions, here everything happens locally.
Here's a reduced version of the code in which I originally encountered this problem, playground.
Meta
The issue persists on beta and nightly.
rustc --version --verbose:
rustc 1.89.0 (29483883e 2025-08-04)
binary: rustc
commit-hash: 29483883eed69d5fb4db01964cdf2af4d86e9cb2
commit-date: 2025-08-04
host: aarch64-apple-darwin
release: 1.89.0
LLVM version: 20.1.7
Metadata
Metadata
Assignees
Labels
C-bugCategory: This is a bug.Category: This is a bug.needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.This issue may need triage. Remove it if it has been sufficiently triaged.