Skip to content

Tracking Issue for impl for<'a> Trait<'a> #104288

Description

@oli-obk

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

Unresolved Questions

Implementation history

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.F-type_alias_impl_trait`#[feature(type_alias_impl_trait)]`

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions