Skip to content

impls with TAIT reject valid unconstraining lifetimes #91601

Open
1 of 1 issue completed
Open
@aliemjay

Description

@aliemjay

I tried this code:

#![feature(impl_trait_in_assoc_type)]

trait Callable {
    type Out;
    fn call() -> Self::Out;
}

impl<'a> Callable for () {
    type Out = impl Sized;
    fn call() -> Self::Out {}
}

(Playground)

I expected this to compile fine since it is accepted without TAIT.

Instead, code was rejected because lifetime 'a is non-constraining.

error[E0207]: the lifetime parameter `'a` is not constrained by the impl trait, self type, or predicates
 --> src/main.rs:8:6
  |
8 | impl<'a> Callable for () {
  |      ^^ unconstrained lifetime parameter

error[E0792]: expected generic lifetime parameter, found `'_`
  --> src/main.rs:10:28
   |
8  | impl<'a> Callable for () {
   |      -- this generic parameter must be used with a generic lifetime parameter
9  |     type Out = impl Sized;
10 |     fn call() -> Self::Out {}
   |                            ^^

Sub-issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.F-type_alias_impl_trait`#[feature(type_alias_impl_trait)]`T-compilerRelevant to the compiler 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