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

attributes: globally qualify attribute paths #3126

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

heaths
Copy link

@heaths heaths commented Oct 30, 2024

Avoid ambiguities with any user-defined tracing modules by globally qualifying types used in the attribute-generated code e.g., ::tracing::Level.

Fixes: #3119 for the v0.2.x crate versions.

Motivation

We need to define helper functions for tracing within our own crates, and tracing is too good a name to pass up. Our helpers will mostly wrap and otherwise "hide" the tracing crate, but when using #[instrument] the generated code conflicts with our tracing module.

Solution

Globally qualify any token paths e.g., ::tracing to avoid ambiguities.

Avoid ambiguities with any user-defined `tracing` modules by globally qualifying types used in the attribute-generated code e.g., `::tracing::Level`.

Fixes: tokio-rs#3119
@heaths heaths requested review from hawkw, davidbarsky and a team as code owners October 30, 2024 06:09
@heaths
Copy link
Author

heaths commented Oct 30, 2024

Note: the CONTRIBUTING.md file recommends updating the CHANGELOG.md but the last entry is very old - over 4 years old; however, the CHANGELOG.md file in the v0.1.x branch is up to date. I plan to make a PR against that branch as well and will update that CHANGELOG.md. I'm happy to update master's as well if that is appropriate.

Copy link
Contributor

@kaffarell kaffarell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM – gave it a quick spin and it works alright. Just FYI, usually PR's are merged on master and then backported by us to v0.1.x.

@heaths
Copy link
Author

heaths commented Oct 30, 2024

Thanks. Should I close the other PR then or will maintainers?

@kaffarell
Copy link
Contributor

No, this PR looks fine, the maintainers are gonna backport everything!

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

Successfully merging this pull request may close these issues.

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