Trait with another type trait bound in where clause - compilation failed

I expected this to work, but compilation fails:

use core::ops::{Add, AddAssign};

pub trait Add1
where
    Self: Sized,
    Self: Add<Self, Output = Self>,
    for<'a> &'a Self: Add<Self, Output = Self>,
    for<'b> Self: Add<&'b Self, Output = Self>,
    for<'c, 'd> &'c Self: Add<&'d Self, Output = Self>,
    Self: AddAssign<Self>,
    for<'e> Self: AddAssign<&'e Self>,
{
}

fn foo<T: Add1>(a: &T, b: &T) {
    unimplemented!()
}

https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=59d1f4f0dd149e254124114645228976

It is obviously some sort of limitation. But is it temporary, or it is by-design? Can anyone provide links to related issues?

This is a known issue, and there are plans to fix it eventually: where clauses are only elaborated for supertraits, and not other things · Issue #20671 · rust-lang/rust · GitHub

See this recent thread for some more information: Fn requires to duplicate trait bounds from a trait

1 Like

Thanks!