Skip to content

Instrumenting async_trait methods drops location of compilation errors #768

Closed
@kleimkuhler

Description

@kleimkuhler

Bug Report

Version

  • tracing v0.1.15
  • tracing-futures v0.2.4

Platform

Linux

Crates

  • async-trait v0.1.36

Description

Instrumenting an async_trait method drops the location of compilation errors.

use async_trait::async_trait;

#[derive(Debug)]
struct A {
    x: usize,
}

#[async_trait]
trait Set {
    async fn set(&mut self);
}

#[async_trait]
impl Set for A {
    #[tracing::instrument]
    async fn set(&mut self) {
        self.x = "error";
    }
}

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

I expected to see the following error from the above:

error[E0308]: mismatched types
  --> src/main.rs:17:18
   |
17 |         self.x = "error";
   |                  ^^^^^^^ expected `usize`, found `&str`

error: aborting due to previous error

Instead, this is the error:

error[E0308]: mismatched types
  --> src/main.rs:15:5
   |
15 |     #[tracing::instrument]
   |     ^^^^^^^^^^^^^^^^^^^^^^ expected `usize`, found `&str`

error: aborting due to previous error

Extra details

I originally came across this error in a less minimal reproduction, but the
error had even less location details as the above.

error[E0277]: the trait bound `(): core::future::future::Future` is not satisfied
  |
  = note: required by `core::future::future::Future::poll`
error: aborting due to previous error

Note that there is no file or code location mentioned!

It was unable to point at the actual #[tracing::instrument] attribute, and on
top of that the error ended up being in a subdirectory of the crate.

I haven't been able to reproduce that in this example.

Metadata

Metadata

Assignees

No one assigned

    Labels

    closed/wontfixThis will not be worked oncrate/attributesRelated to the `tracing-attributes` cratekind/bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions