Closed
Description
STR
#![crate_type = "lib"]
pub trait Bound<T> {}
pub trait Trait: Bound<i8> + Bound<u8> {}
//~^ error: trait `Bound<u8>` already appears in the list of bounds
fn foo<T: Bound<i8> + Bound<u8>>() {}
//~^ error: trait `Bound<u8>` already appears in the list of bounds
fn foo<T>() where T: Bound<i8> + Bound<u8> {} // OK
Due to multidispatch : Bound<i8> + Bound<u8>
is a valid bound, but the compiler is rejecting it in some positions (supertraits and bounds in parameter list), but not in others (where clauses)
Workaround for the supertrait
You can use dummy intermediate traits to indirectly add the "duplicate" bounds, but this is very verbose.
pub trait Bound<T> {}
pub trait Dummy: Bound<i8> {}
pub trait Trait: Dummy + Bound<u8> {} // `Trait` implies `Bound<i8> + Bound<u8>`
Version
rustc 1.0.0-nightly (3ef8ff1f8 2015-02-12 00:38:24 +0000)
Originally reported in #18693 (Niko preferred opening a new issue, instead of re-opening the old one and modifying the original report)