Skip to content

Using associated types in async fn type break typing #60414

Description

@Ekleog

With the following code:

trait Trait {
    type Assoc;
}

async fn foo<T: Trait<Assoc = ()>>() -> T::Assoc {
    ()
}

comes the following error:

error[E0271]: type mismatch resolving `<impl std::future::Future as std::future::Future>::Output == <T as Trait>::Assoc`
 --> src/lib.rs:7:41
  |
7 | async fn foo<T: Trait<Assoc = ()>>() -> T::Assoc {
  |                                         ^^^^^^^^ expected (), found associated type
  |
  = note: expected type `()`
             found type `<T as Trait>::Assoc`
  = note: the return type of a function must have a statically known size

error: aborting due to previous error

(playground link)

However, this function compiles correctly without the async keyword.

Activity

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

Metadata

Metadata

Labels

A-async-awaitArea: Async & AwaitA-impl-traitArea: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.AsyncAwait-PolishAsync-await issues that are part of the "polish" areaC-bugCategory: This is a bug.T-compilerRelevant to the compiler 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