I've got a bunch of traits extending other traits, adding restrictions to associated types at each step along the chain.
Dummy associated types let me propagate the bounds after introduction, up until the last one, which doesn't seem to stick for some reason. Is there a way to remove the redundant trait bound?
trait HasAValue {
type X;
fn x(&self) -> Self::X;
}
trait HasASignedValue: HasAValue {
type _X: num::Signed;
}
impl<T> HasASignedValue for T
where
T: HasAValue,
T::X: num::Signed
{
type _X = T::X;
}
trait HasAnI32: HasASignedValue<X = i32> {}
trait HasASignedInt: HasASignedValue
where
Self::X: num::Integer,
{
type _X: num::Integer;
}
impl<T> HasASignedInt for T
where
T: HasASignedValue,
T::X: num::Integer
{
type _X = T::X;
}
fn _some_function<T>(val: T) -> T
where
T: HasASignedInt,
T::X: num::Integer // Don't want. Implied by trait bound
{
val
}
fn main() {}
Errors:
Compiling playground v0.0.1 (/playground)
Finished dev [unoptimized + debuginfo] target(s) in 0.39s
Running `target/debug/playground`