Skip to content

Remove cfg(test) from doc_auto_cfg #91740

Closed
@daxpedda

Description

@daxpedda

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-rustdoc-uiArea: Rustdoc UI (generated HTML)F-doc_auto_cfg`#![feature(doc_auto_cfg)]`F-doc_cfg`#![feature(doc_cfg)]`T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions