higher ranked lifetimes not recognized by type alias impl trait · Issue #96146 · rust-lang/rust (original) (raw)

Skip to content

Provide feedback

Saved searches

Use saved searches to filter your results more quickly

Sign up

Appearance settings

@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)