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

Remove cfg(test) from doc_auto_cfg #91740

Closed
daxpedda opened this issue Dec 10, 2021 · 1 comment · Fixed by #92856
Closed

Remove cfg(test) from doc_auto_cfg #91740

daxpedda opened this issue Dec 10, 2021 · 1 comment · Fixed by #92856
Labels
A-rustdoc-ui Area: rustdoc UI (generated HTML) F-doc_auto_cfg `#![feature(doc_auto_cfg)]` F-doc_cfg `#![feature(doc_cfg)]` T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@daxpedda
Copy link
Contributor

daxpedda commented Dec 10, 2021

From #43781 (comment) and #43781 (comment).

Currently #[cfg(any(feature = "danger", test))] shows up as:
grafik

This seems to be undesired behavior. I'm not familiar with the Rust compiler, but looking through the code lead me to the conclusion that the best way to do this is transform Attributes, removing undesired cfgs before passing them to further processing.

The current implementation of doc_hide_cfg can only remove cfgs that have an exact match. #![doc(cfg_hide(feature = "x"))] can only hide #[cfg(feature = "x")], it can't hide #[cfg(any(feature = "x", feature = "y"))] or #[cfg(all(feature = "x", feature = "y"))]. So my impression is that we can't hook into doc_hide_cfg to solve this.

Implementing what I described above could also pave the way to adjust the behaviour of cfg_hide and allow it to match for cfgs inside any and all, if this is desired.

Cc #43781.

@Nemo157 Nemo157 added A-rustdoc-ui Area: rustdoc UI (generated HTML) T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. F-doc_auto_cfg `#![feature(doc_auto_cfg)]` F-doc_cfg `#![feature(doc_cfg)]` labels Dec 10, 2021
@jyn514
Copy link
Member

jyn514 commented Dec 10, 2021

So my impression is that we can't hook into doc_hide_cfg to solve this.

@Nemo157 actually suggested giving it the behavior you're describing originally, it just turned out to be a little trickier than expected so we delayed it with the goal of being able to land the PR at all. If you can get it to work that would be super helpful!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-rustdoc-ui Area: rustdoc UI (generated HTML) F-doc_auto_cfg `#![feature(doc_auto_cfg)]` F-doc_cfg `#![feature(doc_cfg)]` T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants