Tracking issue for existential lifetimes #60670
Labels
A-impl-trait
Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.
A-lifetimes
Area: Lifetimes / regions
A-type-system
Area: Type system
T-lang
Relevant to the language team, which will review and decide on the PR/issue.
T-types
Relevant to the types team, which will review and decide on the PR/issue.
This is a tracking issue for existential lifetimes.
Description:
Allow hiding a type (via
impl Trait
) that is invariant over some lifetime without explicitly mentioning the invariant lifetime.Consider the following:
There is no reason this cannot be legal, although it is not permitted at present. We would want to translate the function signature internally into something like:
Although it be noted there is no need for user-facing
exists<...>
syntax; only HIR andty
representations probably. The concrete type corresponding toimpl exists<'x: 'y> Trait<'y>
can this be soundly checked by the compiler at use site.Note, we still need to be careful to ban situations like those mentioned by @matthewjasper in #59402. By actually embedding the existential lifetime in the type rather than simply doing a check when resolving the opaque type, we should be able to resolve these issues, however. One can view this solution as a "compiler-internalised" version of the
Captures
marker trait solution, in some sense.Steps:
impl Trait
#57870 and Allow hidden lifetimes inimpl Trait
, take 2 #59402, @nikomatsakis for mentoring instructions?)CC @Centril @nikomatsakis @matthewjasper @cramertj
The text was updated successfully, but these errors were encountered: