dtolnay / async-trait

Type erasure for async trait methods
Apache License 2.0
1.84k stars 85 forks source link

Build error when using tracing crate #156

Closed krojew closed 3 years ago

krojew commented 3 years ago

Some changes since version 0.1.42 cause problems when also using the tracing crate. This example code:

#[async_trait]
impl SomeTrait for SomeType {
    #[instrument(skip(self), err)]
    async fn some_fn(&self) -> Result<(), String> {
        ...
    }
}

results in the following build error:

expected struct `Pin`, found enum `std::result::Result`
this expression has type `Pin<Box<impl futures::Future>>`

0.1.42 works fine. Rust version: rustc 1.52.0-nightly (45b3c2851 2021-03-04)

dtolnay commented 3 years ago

This needs to be fixed in the tracing crate. There is some work in https://github.com/tokio-rs/tracing/pull/1228.

nightmared commented 3 years ago

This is merged in tracing, I don't know if a release will be published soon, but I guess you can point to the git repo meanwhile.

nightmared commented 3 years ago

Edit: tracing-attributes 0.1.14 was just published! See https://crates.io/crates/tracing-attributes/0.1.14