// check-pass // compile-flags: -Ztrait-solver=next trait Foo { type Gat<'a> where Self: 'a; fn bar(&self) -> Self::Gat<'_>; } enum Option { Some(T), None, } impl Option { fn as_ref(&self) -> Option<&T> { match self { Option::Some(t) => Option::Some(t), Option::None => Option::None, } } fn map(self, f: impl FnOnce(T) -> U) -> Option { match self { Option::Some(t) => Option::Some(f(t)), Option::None => Option::None, } } } impl Foo for Option { type Gat<'a> = Option<::Gat<'a>> where Self: 'a; fn bar(&self) -> Self::Gat<'_> { self.as_ref().map(Foo::bar) } } fn main() {}