Skip to content

higher ranked lifetimes not recognized by type alias impl trait #96146

Open
@oli-obk

Description

@oli-obk

The following snippet fails

#![feature(type_alias_impl_trait)]
trait Trait<'a> { type Out: 'a;}
impl<'a> Trait<'a> for i32 { type Out = String;}
type A = impl for<'a> Trait<'a, Out = impl Sized + 'a>;
fn foo() -> A {
    0_i32
}

The error is

error: non-defining opaque type use in defining scope
 --> src/lib.rs:6:5
  |
6 |     0_i32
  |     ^^^^^
  |
note: used non-generic lifetime `'a` for generic parameter
 --> src/lib.rs:4:52
  |
4 | type A = impl for<'a> Trait<'a, Out = impl Sized + 'a>;
  |                                                    ^^

Originally posted by @oli-obk in #96094 (comment)

Metadata

Metadata

Assignees

Labels

A-higher-rankedArea: Higher-ranked things (e.g., lifetimes, types, trait bounds aka HRTBs)A-impl-traitArea: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.C-bugCategory: This is a bug.F-type_alias_impl_trait`#[feature(type_alias_impl_trait)]`T-typesRelevant to the types team, which will review and decide on the PR/issue.

Type

No type

Projects

Status

Can do after stabilization

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions