You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Same trait with different input concrete parameters are considered duplicate bounds (: Bound<i8> + Bound<u8>) #22279
#![crate_type = "lib"]pubtraitBound<T>{}pubtraitTrait:Bound<i8> + Bound<u8>{}//~^ error: trait `Bound<u8>` already appears in the list of boundsfnfoo<T:Bound<i8> + Bound<u8>>(){}//~^ error: trait `Bound<u8>` already appears in the list of boundsfnfoo<T>()whereT: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.
This was an intentional limitation, but it really doesn't make a lot of sense in a multidispatch world, and is also often something you can workaround with where clauses.
@nikomatsakis it seems like if we commit to the supertrait/bounds changes that I started this should no longer be an issue since all bounds end up being checked by a single code path. Just an observation.
Activity
nikomatsakis commentedon Feb 13, 2015
This was an intentional limitation, but it really doesn't make a lot of sense in a multidispatch world, and is also often something you can workaround with where clauses.
jroesch commentedon Feb 14, 2015
@nikomatsakis it seems like if we commit to the supertrait/bounds changes that I started this should no longer be an issue since all bounds end up being checked by a single code path. Just an observation.
nikomatsakis commentedon Mar 3, 2015
I've wound up fixing this as part of another patch (partly due to what @jroesch was saying).
jroesch commentedon Mar 4, 2015
👍