Skip to content

Generated #[instrument] code is not qualified to the tracing crate #3119

@heaths

Description

@heaths

Bug Report

Version

  • tracing 0.1.40

Platform

Darwin Mac.localdomain 24.0.0 Darwin Kernel Version 24.0.0: Tue Sep 24 23:38:45 PDT 2024; root:xnu-11215.1.12~1/RELEASE_ARM64_T8122 arm64

Crates

tracing

Description

I created a tracing module in my crate to add a bunch of helpers for my use of the tracing crate. Probably not the best idea, but technical should work and naming is hard. I changed imports to use ::tracing::{instrument, Level} but then I was getting compiler errors like:

failed to resolve: could not find `span` in `tracing`
could not find `span` in `tracing`

failed to resolve: could not find `event` in `tracing`
could not find `event` in `tracing`

failed to resolve: could not find `Instrument` in `tracing`
could not find `Instrument` in `tracing`

lib.rs(9, 1): consider importing one of these traits: `use crate::instrument::Instrument;
`, `use ::tracing::Instrument;
`

If I rename my crate to something else - leaving the tracing crate import as either ::tracing or tracing, the generated code compiles fine. Perhaps the generated code should be emitting ::tracing as the prefix to avoid conflicts?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions