There isn't one today. It comes up quite frequently, so you can find many other discussions in this forum or on internals (search for self referential), but here are some simple examples of things that must be handled:
struct StringParts {
data: String,
// Note: lifetimes are a static analysis of code and are erased during
// compilation; they are not present during runtime and they are not
// a property that data structures dynamically "carry around" with them.
// But for the sake of illustration...
prefix: &'self.data str,
suffix: &'self.data str,
}
// Assume everything else works like it does in today's Rust
fn dangle_via_reallocation(sp: &mut StringParts) {
let size_that_must_reallocate = 3 * (sp.data.capacity() + 1);
sp.data.reserve(size_that_must_reallocate);
// `prefix` and `suffix` are now invalid
}
fn references_implement_copy(sp: &StringParts) -> StringParts {
StringParts {
data: String::new(),
prefix: sp.prefix,
suffix: sp.suffix,
}
}
fn dangle_after_reference_copy(sp: StringParts) {
let other = references_implement_copy(&sp);
drop(sp);
// Oops, other.prefix and other.suffix now dangle
}
// Note: no allocation in this example, all the data lives on the stack.
// Also no need to implement `Copy` -- moves are not the same thing.
struct ArrayParts {
data: [u8; 16],
prefix: &'self.data [u8],
suffix: &'self.data [u8],
}
fn take_by_value(ap: ArrayParts) {
// When you call this function, the `ArrayParts` you pass in may get
// copied to a new place on the stack (moved). In which case,
// `ap.prefix` and `ap.suffix` are dangling before you do anything.
}
In the Rust of today, you have to use unsafe and work very hard to avoid such dangles, not leak references (which implement Copy), uphold the "no aliases during mutation" contract, and so on. That's what the crates you mentioned aim to do.
So if it makes it into the language at some point, it will be a rather large change. If they're implemented using lifetimes, they won't really be the same thing that lifetimes are today (e.g. they'll have to penetrate the function declaration API, or there'll be a new syntax, etc.). And the references will probably be a new thing too (e.g. somehow heap-or-stack-aware, with the latter being implemented as a relative offset), though maybe Pin could be enough.
As far as I know there's still an interest in the teams, but I imagine it's quite a long way off. If you feel you really need it (versus e.g. using indices, ranges, interior mutability, Rc, etc), I suggest looking for a crate you feel highly confident in.