External Publication
Visit Post

[Pre-pre RFC] Allow exclusion of trait methods for (certain) unsatisfiable where bounds

Rust Internals [Unofficial] April 9, 2026
Source

Apersoma:

Right now, there is no way to implement Foo for a type that doesn't implement Bar without refining fn func to not have the bound, defeating its entire purpose.

You might be interested to learn that actually one can add the bound: For some reason, rustc doesn’t care so much anymore about “impossible” bounds if you add some higher-ranked lifetime to it. So e.g. while

impl Foo for SomeType {
    fn func(self) -> Self
    where
        Self: Bar,
    {
        unreachable!()
    }
}

is rejected, doing this instead is actually accepted:

impl Foo for SomeType {
    fn func(self) -> Self
    where
        for<'a> Self: Bar,
    {
        unreachable!()
    }
}

(equivalently: Self: for<'a> Bar. Also I somethimes would write this using for<'__> Self: Bar marking the name of the lifetime more clearly “irrelevant”, arguably.)

Discussion in the ATmosphere

Loading comments...