Skip to content

Regression of TAIT with generics #114909

Closed
@xxchan

Description

@xxchan

I tried this code:

#![feature(type_alias_impl_trait)]

struct Foo;

impl Trait for Foo {}
pub trait Trait {}

pub type TAIT<T> = impl Trait;

async fn foo<T>() -> TAIT<T> {
    Foo
}

It failed with a confusing error message. (error: concrete type differs from previous defining opaque type use, at the same location)

error: concrete type differs from previous defining opaque type use
  --> src/main.rs:11:5
   |
11 |     Foo
   |     ^^^ expected `TAIT<T>`, got `Foo`
   |
note: previous use here
  --> src/main.rs:10:30
   |
10 |   async fn foo<T>() -> TAIT<T> {
   |  ______________________________^
11 | |     Foo
12 | | }
   | |_^

I'm trying to minimize #114727, and found the problem.

nightly-2023-06-17 compiles, but nightly-2023-06-18 fails. Although not 100% sure, I think it's caused by the same problem as #114727 (regression caused by #108860)

Metadata

Metadata

Labels

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

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions