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

subscriber: Stop using prelude imports in doctests #1422

Merged
merged 2 commits into from
Jun 7, 2021

Conversation

jplatte
Copy link
Member

@jplatte jplatte commented Jun 4, 2021

Motivation

I dislike using * imports in my code, so I'm not using prelude modules provided by libraries. With the way the examples in the tracing-subscriber docs are currently set up, there is no hint on where some methods are coming from. Just removing the prelude import unfortunately doesn't lead to a solution. The compiler prefers the prelude re-export:

    = help: items from traits can only be used if the trait is in scope
help: the following trait is implemented but not in scope; perhaps add a `use` for it:
    |
3   | use crate::tracing_subscriber::prelude::__tracing_subscriber_SubscriberExt;
    |

Solution

Use the traits directly in the documentation examples.

@jplatte jplatte requested review from davidbarsky, hawkw and a team as code owners June 4, 2021 19:34
jplatte added 2 commits June 5, 2021 00:04
Since the compiler hints around this are currently very bad, it's good
to have a hint where methods in doc examples could come from in there,
for users who prefer not using the prelude.
@jplatte
Copy link
Member Author

jplatte commented Jun 5, 2021

CI jobs need re-approval to run.

@jplatte
Copy link
Member Author

jplatte commented Jun 5, 2021

Related: rust-lang/rust#86035

@hawkw hawkw merged commit 44d3558 into tokio-rs:master Jun 7, 2021
@jplatte jplatte deleted the doc-no-prelude branch June 7, 2021 17:36
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.

2 participants