This currently fails to compile:
trait Trait { fn asdf() {} }
trait A {}
trait B {}
impl<T> Trait for T where T: A {}
impl<T> Trait for T where T: B {}
with error:
<anon>:8:1: 8:34 error: conflicting implementations for trait `Trait` [E0119]
<anon>:8 impl<T> Trait for T where T: A {}
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<anon>:9:1: 9:34 note: note conflicting implementation here
<anon>:9 impl<T> Trait for T where T: B {}
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
error: aborting due to previous error
Rust Playpen Link
Naturally, this error makes sense. A type can impl both traits A and B. I was hoping that such a check could be deferred, though, thus resolving these 'conflicts' later when something actually asking for Trait pops up. Ex. a type that impls only A would get the blanket impl for A, and if multiple impls apply (e.g. the type impls both A and B) then the compiler errors out.
Some ideas
It was suggested on IRC that one may allow both blanket impls to apply by using UFCS path syntax to disambiguate trait bounds and narrow down the possibly applicable impls to a single one. Ex. a type that impls both A and B could get both blanket impls but be disambiguated when calling via <Type as A>::asdf().
But really I'd be totally cool with only one blanket impl applying to any one type at any time.
This currently fails to compile:
with error:
Rust Playpen Link
Naturally, this error makes sense. A type can
implboth traitsAandB. I was hoping that such a check could be deferred, though, thus resolving these 'conflicts' later when something actually asking forTraitpops up. Ex. a type thatimpls onlyAwould get the blanketimplforA, and if multipleimpls apply (e.g. the typeimpls bothAandB) then the compiler errors out.Some ideas
It was suggested on IRC that one may allow both blanket
impls to apply by using UFCS path syntax to disambiguate trait bounds and narrow down the possibly applicableimpls to a single one. Ex. a type thatimpls bothAandBcould get both blanketimpls but be disambiguated when calling via<Type as A>::asdf().But really I'd be totally cool with only one blanket
implapplying to any one type at any time.