-
Notifications
You must be signed in to change notification settings - Fork 710
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
subscriber: re-export prelude traits as _
#1850
base: v0.1.x
Are you sure you want to change the base?
Conversation
Currently, the `tracing-subscriber` prelude re-exports some traits as `__tracing_subscriber_<TRAIT NAME>` to avoid namespace conflicts. This is because those traits were added to the prelude before `use Trait as _` was available in stable Rust. In some cases, this can apparently result in weird error messages (see #1847). This commit changes the prelude to re-export everything `as _`. In theory, this is _technically_ a breaking change in case anyone is actually referring to traits as the re-exported names in the prelude. However, I don't think it's likely that anyone's actually doing this, and they shouldn't be considered stable API, so I don't think this needs to wait for a breaking release. If anyone disagrees, I'm open to being convinced otherwise. Fixes #1847
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.
approved pending compile errors
I think that Vector is the main public user of the re-exported prelude traits (see this search, cc: @tobz). |
I haven't gotten into the GitHub code search beta yet (just signed up), can you share a link that I can actually view? |
If anyone is actually using the prelude types by name, though...
|
The compiler errors look like the |
Ah, sorry about that. Here's a set of uses on the non-beta code search.
I think that rust-analyzer automatically suggests importing those re-exported prelude traits and isn't able to see through to the actual trait. I've had that happen a few times.
i agree |
Hmm, okay, the number of results in that search is making me significantly less comfortable about changing this in a non-breaking release. I think it might be better off waiting for 0.4. That's really disappointing. :/ |
I can tell you that I almost exclusively use VS Code/Rust Analyzer's feature to automatically add the import statement for a given type, so I guess Rust Analyzer is finding matching types and because of the Might also be worth reaching out to the RA team since it does seem like a weird behavior for it to suggest them when they wouldn't otherwise come up in normal API documentation, etc. |
Maybe you could do something like pub use crate::layer::{Layer as _, SubscriberExt as _};
// Remove in 0.4
#[doc(hidden)]
pub use crate::layer::{
Layer as __tracing_subscriber_Layer, SubscriberExt as __tracing_subscriber_SubscriberExt,
}; I don't know if this will fix error messages, but it will at least get rid of the weirdness in the published docs. |
Ooh, can you deprecate re-exports? That might be nice too. |
@lilyball: It might be worth using the approach in your first comment, though, if that fixes the weird error messages. It would be nicer if we could emit deprecation warnings when |
Currently, the
tracing-subscriber
prelude re-exports some traits as__tracing_subscriber_<TRAIT NAME>
to avoid namespace conflicts. Thisis because those traits were added to the prelude before
use Trait as _
was available in stable Rust. In some cases, this can apparentlyresult in weird error messages (see #1847).
This commit changes the prelude to re-export everything
as _
. Intheory, this is technically a breaking change in case anyone is
actually referring to traits as the re-exported names in the prelude.
However, I don't think it's likely that anyone's actually doing this,
and they shouldn't be considered stable API, so I don't think this needs
to wait for a breaking release. If anyone disagrees, I'm open to being
convinced otherwise.
Fixes #1847