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

blanket 0.4 + async-trait don't work together #13

Open
nwalfield opened this issue Mar 16, 2024 · 0 comments
Open

blanket 0.4 + async-trait don't work together #13

nwalfield opened this issue Mar 16, 2024 · 0 comments

Comments

@nwalfield
Copy link

blanket 0.4 works with async traits (yay!). Unfortunately, async traits in Rust are still rather limited in functionality so it is often necessary to use the async-trait crate. Unfortunately, blanket does not work with traits that use async-trait. Consider the following code:

trait Foo {
    fn foo();
}

#[blanket::blanket(derive(Box, Mut))]
trait Bar {
    async fn bar();
}

#[blanket::blanket(derive(Box, Mut))]
#[async_trait::async_trait]
trait Xyzzy {
    async fn xyzzy();
}

fn main() {
    println!("Hello, world!");
}

In the Cargo.toml, I have:

[dependencies]
blanket = "0.4"
async-trait = "0.1"

When compiling the above, I get:

$ cargo build
   Compiling async-blanket v0.1.0 (/tmp/async-blanket)
error[E0195]: lifetime parameters or bounds on method `foo` do not match the trait declaration
  --> src/main.rs:13:17
   |
13 |     async fn xyzzy();
   |              ---^-
   |              |  |
   |              |  lifetimes do not match method in trait
   |              lifetimes in impl do not match this method in trait

For more information about this error, try `rustc --explain E0195`.
error: could not compile `async-blanket` (bin "async-blanket") due to 2 previous errors
$ rustc --version
rustc 1.76.0 (07dca489a 2024-02-04)
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