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

rustdoc: move #[macro_use] extern crate statements outside the generated main in doctests #49174

Closed
QuietMisdreavus opened this issue Mar 19, 2018 · 3 comments
Labels
C-enhancement Category: An issue proposing an enhancement or a PR with one. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@QuietMisdreavus
Copy link
Member

In #48106 i moved plain extern crate some_crate statements outside the fn main that rustdoc generates, but i failed to take #[macro_use] attributes into account. Since one of the common reasons people would add the manual crate import is to import its macros, this makes the feature less useful.

(Mentoring instructions to follow...)

@QuietMisdreavus QuietMisdreavus added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. C-enhancement Category: An issue proposing an enhancement or a PR with one. labels Mar 19, 2018
@QuietMisdreavus
Copy link
Member Author

To make a PR for this, you can effectively follow the blueprint in #48106. There's a conditional in partition_source in src/librustdoc/test.rs that checks for inner attributes and extern crate statements, so the change is as small as adding another condition to check for lines starting with #[macro_use] extern crate as well. You should also add another test to the grouping of unit tests at the bottom of the file to make sure it works.

If you run into issues in the error index like i did in the original PR, we can deal with it after the PR is put up. If you want to take this PR on, comment here or find me in #rustdoc on IRC!

@QuietMisdreavus QuietMisdreavus added E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. labels Mar 19, 2018
@memoryleak47
Copy link
Contributor

I'd like to try this one. :)

@QuietMisdreavus
Copy link
Member Author

Great! Let me know if you run into any issues or want some help. :D

kennytm added a commit to kennytm/rust that referenced this issue Mar 21, 2018
…uietMisdreavus

Put `#[macro_use] extern crate <crate>` before fn main() in doctests

Closes rust-lang#49174.
kennytm added a commit to kennytm/rust that referenced this issue Mar 22, 2018
…uietMisdreavus

Put `#[macro_use] extern crate <crate>` before fn main() in doctests

Closes rust-lang#49174.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: An issue proposing an enhancement or a PR with one. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

2 participants