Tracking Issue for impl for<'a> Trait<'a>
· Issue #104288 · rust-lang/rust (original) (raw)
Some context can be found in this comment.
We would like to support using higher kinded lifetimes in opaque types.
At present
#![feature(type_alias_impl_trait)]
trait Tr<'a> { type Assoc; }
impl<'a> Tr<'a> for () { type Assoc = (); }
type Associated<'a> = impl Copy; type Associated2<'a> = impl Copy + 'a;
fn f() -> impl for<'a> Tr<'a, Assoc = Associated2<'a>> {} fn f1() -> impl for<'a> Tr<'a, Assoc = Associated<'a>> {}
impl<'a> Tr<'a> for i32 { type Assoc = &'a (); }
fn f2() -> impl for<'a> Tr<'a, Assoc = Associated2<'a>> { 42_i32 } fn f3() -> impl for<'a> Tr<'a, Assoc = Associated<'a>> { 42_i32 }
errors, though with a different error message than the equivalent code for RPIT.
An implementation should also add tests that actually use the higher kinded lifetimes, e.g. via closures or similar datastructures.
About tracking issues
Tracking issues are used to record the overall progress of implementation.
They are also used as hubs connecting to other relevant issues, e.g., bugs or open design questions.
A tracking issue is however not meant for large scale discussion, questions, or bug reports about a feature.
Instead, open a dedicated issue for the specific matter and add the relevant feature gate label.
Steps
- Replace the error from Forbid nested opaque types to reference HRTB from opaque types. #97039 with a feature gate and then implement meaningful semantics.
- Adjust documentation (see instructions on rustc-dev-guide)
- Stabilization PR (see instructions on rustc-dev-guide)