Consider this code:
#![feature(specialization)]
trait Foo {
fn bar();
}
trait A {}
trait B {}
impl<T: A> Foo for T {
fn bar() { println!("A") }
}
impl<T: B> Foo for T {
fn bar() { println!("B") }
}
impl<T: A + B> Foo for T {
fn bar() { println!("A + B") }
}
Currently this doesn't build on nightly (nor in the chalk repl) because the impls for T: A
and T: B
overlaps, however the overlapping part is specialized in another impl
, so this shouldn't be ambiguous. Unfortunately the specialization
RFC doesn't seem to cover this case. Is there a workaround for this or should I propose in IRLO to expand the RFC to cover cases like this?