Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for impl Trait in associated type (type_alias_impl_trait) #152

Closed
dtolnay opened this issue Mar 7, 2021 · 0 comments · Fixed by #153
Closed

Support for impl Trait in associated type (type_alias_impl_trait) #152

dtolnay opened this issue Mar 7, 2021 · 0 comments · Fixed by #153

Comments

@dtolnay
Copy link
Owner

dtolnay commented Mar 7, 2021

The following async trait fails to compile. This worked prior to #143.

#![feature(type_alias_impl_trait)]

use async_trait::async_trait;

#[async_trait]
trait Trait {
    type Assoc;

    async fn f(&self) -> Self::Assoc;
}

struct Struct;

#[async_trait]
impl Trait for Struct {
    type Assoc = impl Sized;

    async fn f(&self) -> Self::Assoc {}
}
error[E0308]: mismatched types
  --> src/main.rs:18:14
   |
16 |     type Assoc = impl Sized;
   |                  ---------- the expected opaque type
17 | 
18 |     async fn f(&self) -> Self::Assoc {}
   |              ^
   |              |
   |              expected opaque type, found `()`
   |              implicitly returns `()` as its body has no tail or `return` expression
   |
   = note: expected opaque type `impl Sized`
                found unit type `()`

error: could not find defining uses
  --> src/main.rs:16:18
   |
16 |     type Assoc = impl Sized;
   |                  ^^^^^^^^^^
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant