Description
Arguably, trait alias refs should bring along ambient object lifetime defaults (I would say "just like trait refs" but those are currently unintentionally broken (or have been since their introduction) which would get fixed in #129543).
TL;DR: This code should compile and doesn't currently:
#![feature(trait_alias)]
trait Container<'a, T: 'a + ?Sized> =;
trait Bound {}
fn f<'r, T>() where T: Container<'r, dyn Bound + 'r> { g::<'r, T>() }
fn g<'r, T>() where T: Container<'r, dyn Bound> {}
// ^^^^^^^^^ we currently deduce `dyn Bound + 'static` since trait alias
// `Container` is not considered an eligible generic container.
// However, we should make it one and deduce `dyn Bound + 'r`.
error: lifetime may not live long enough
--> src/lib.rs:7:56
|
7 | fn f<'r, T>() where T: Container<'r, dyn Bound + 'r> { g::<'r, T>() }
| -- lifetime `'r` defined here
Object lifetime defaults aren't a hot topic esp. due to the existence of inferred outlives-bounds which don't participate in their resolution, so this is generally P-low but I'm not marking this issue as such as it should still block the stabilization of trait_alias
(or whatever features end up replacing it) since modifying the resolution of object lifetime default afterwards would be a breaking change.
Temporarily blocking this on my PR #129543 which touches a lot of code in that area.