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

type parameter is part of concrete type but not used in parameter list for the impl Trait type alias #8

Open
netthier opened this issue Sep 3, 2022 · 0 comments

Comments

@netthier
Copy link

netthier commented Sep 3, 2022

It seems like the macro doesn't support implementing traits for structs with generic parameters like:

trait Foo {}
struct Bar<F: Foo> { f: F }

#[real_async_trait]
trait Bat {
    async fn baz();
}

#[real_async_trait]
impl<F: Foo> Bat for Bar<F> {
    async fn baz() { }
}

Compilation fails with the error

error: type parameter `F` is part of concrete type but not used in parameter list for the `impl Trait` type alias
  --> src/main.rs:13:1
   |
13 | #[real_async_trait]
   | ^^^^^^^^^^^^^^^^^^^
   |
   = note: this error originates in the attribute macro `real_async_trait` (in Nightly builds, run with -Z macro-backtrace for more info)

Manually typing out the async trait definition and implementation works:

trait Foo {}
struct Bar<F: Foo> { f: F }

trait Bat {
    type BazFuture<'a>: Future<Output = ()>;
    fn baz<'a>() -> Self::BazFuture<'a>;
}

impl<F: Foo> Bat for Bar<F> {
    type BazFuture<'a> = impl Future<Output = ()>;
    fn baz<'a>() -> Self::BazFuture<'a> { async move { } }
}
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

No branches or pull requests

1 participant