Leaky trait bounds

I have code which looks roughly like this:

use typenum::{IsLess, Le, NonZero, Unsigned, U256};

pub trait Foo
where
    Self::Size: IsLess<U256>,
    Le<Self::Size, U256>: NonZero,
{
    type Size: Unsigned;
}

pub trait Bar: Foo {}

Playground

But compiler refuses to accept this code and insists on duplicating the bounds on Size in the Bar trait. What is the reason for that? If a type implements Foo (which is required for implementing Bar), then the bound on Size has to be satisfied.

Is it a deficiency of the current version of the Rust compiler? If yes, are there plans to fix it?

Issue: where clauses are only elaborated for supertraits, and not other things

Plan (as far as I'm aware): RFC 2089 Implied Bounds

2 Likes