Skip to content

tracing-attributes 0.1.14 causes variables to be out of scope when they're in scope #1296

@jeromegn

Description

@jeromegn

Bug Report

Version

│   │   └── tracing v0.1.25
│   │       ├── tracing-attributes v0.1.14 (proc-macro)
│   │       └── tracing-core v0.1.17
│   ├── tracing v0.1.25 (*)
│   └── tracing v0.1.25 (*)
│   └── tracing v0.1.25 (*)
├── tracing v0.1.25 (*)
├── tracing-core v0.1.17 (*)
├── tracing-futures v0.2.5
│   └── tracing v0.1.25 (*)
├── tracing-log v0.1.2
│   └── tracing-core v0.1.17 (*)
├── tracing-subscriber v0.2.16
│   ├── tracing v0.1.25 (*)
│   ├── tracing-core v0.1.17 (*)
│   ├── tracing-log v0.1.2 (*)
│   └── tracing-serde v0.1.2
│       └── tracing-core v0.1.17 (*)

Platform

Darwin Kernel Version 20.3.0 (AMR64)

Crates

tracing-attributes

Description

Upgrading to tracing-attributes 0.1.14 appears to be placing variables out of scope.

I don't exactly have a minimal reproduction, but here's roughly the code that causes it:

#[instrument(skip(self, req), fields(app_id))]
fn call(&mut self, req: (Req, IpAddr)) -> Self::Future {
    // ...
    let metrics = self.metrics.clone();
    // ...
    Box::pin(async move {
        // ...
        metrics // cannot find value `metrics` in this scope
    })
}

Removing #[instrument(...)] fixes the issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    crate/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