-
Notifications
You must be signed in to change notification settings - Fork 823
attributes: globally qualify attribute paths #3126
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
Conversation
Note: the |
There was a problem hiding this 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.
Thanks. Should I close the other PR then or will maintainers? |
No, this PR looks fine, the maintainers are gonna backport everything! |
@davidbarsky @hawkw is this good? Want me to rebase on another branch or anything? We'd love to get this fix to unblock some of our scenarios. |
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
Avoid ambiguities with any user-defined `tracing` modules by globally qualifying types used in the attribute-generated code e.g., `::tracing::Level`.
Avoid ambiguities with any user-defined `tracing` modules by globally qualifying types used in the attribute-generated code e.g., `::tracing::Level`.
Hey, just a heads-up that this is a breaking change in some situations, as global paths don't work with crate re-exports. In our code base we have a shared library across multiple repositories, and this library re-exports commonly used crates (including tracing) to make version management easier. Previously we could do |
Makes sense. However, what you were doing before was never meant to be supported, to my understanding. |
If you need a new hack, you can add use lib::tracing::*;
extern crate self as tracing; to your crate roots. I wouldn't recommend it over the explicit dependency, just pointing out it's possible 😅 |
I think the problem here is that we can either support users having some module called However, I don't believe that we can support both cases at the same time. If you know a way, please let me know. I appreciate that this is a breaking change for you, and I don't want to downplay that, but we're really considering the previous behavior of not using an absolute path as a defect that should be fixed and how the macro should have been implemented all along. |
Yes, I agree, this is an understandable change, and I'm not asking for it to be reverted. Just writing a heads-up in case anyone else encounters this (and perhaps this could also be mentioned in the changelog). |
@ilya-zlobintsev Thank you for the heads up and for the understanding. This was missed from the |
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" thetracing
crate, but when using#[instrument]
the generated code conflicts with ourtracing
module.Solution
Globally qualify any token paths e.g.,
::tracing
to avoid ambiguities.