Why do lifetimes need to be leaky?
There's a very infamous problem in Rust regarding lifetimes, and it's that use of lifetimes is often a leaky abstraction:
struct Foo<'a> {
x: &'a str,
}
And now every struct and function that wishes to use this struct will also need to be generic over lifetime 'a, further causing leaks.
Why don't we simply have something like a 'super?
struct Foo {
x: &'super str,
}
Why would we need to specify any other lifetime anyway other than to just ensure the referenced variable lives as long as its parent struct? In that case, why even have 'super? That should be implicit, no? And barring that, why do we even need to specify lifetimes for anything? Is it a technical limitation? Clearly if the borrowck is capable of checking if lifetimes last as long, it must mean it already knows the lifetime of the referenced variable, so why not the 'a lifetime be the same as the lifetime borrowck decides automatically? Even in cases where sometimes some variables need to be stated to have different lifetimes, to circumvent some covariant/invariant issues (see the classic Crust of Rust video on lifetimes for that), if we don't try to coalesce all implicit lifetimes to one, this shouldn't be a problem right?
EDIT: To clarify a bit, I'm more curious what would've happened if lifetime annotations (lifetimes are necessary and I agree with that) were implicit, and only checked lazily (still at compile-time), and yes that would mean that lazy checking would lead to Rust breaking its principle of only needing to know function signatures. That would help me understand better why we don't do it that way.