Skip to content

rustdoc: correctly propagate cfgs for glob reexports#157039

Open
lcian wants to merge 1 commit into
rust-lang:mainfrom
lcian:fix/glob-reexport-feature-combination
Open

rustdoc: correctly propagate cfgs for glob reexports#157039
lcian wants to merge 1 commit into
rust-lang:mainfrom
lcian:fix/glob-reexport-feature-combination

Conversation

@lcian
Copy link
Copy Markdown

@lcian lcian commented May 27, 2026

This fixes some cases of rustdoc not surfacing the correct required feature combination when using #[cfg(feature = ...)] in combination with glob reexports.

See the example cases included as tests.

Here's the generated HTML for those test cases before this change:
Screenshot_20260528_090523

and after:
Screenshot_20260528_090553

My understanding is that this was basically an off-by-one type of oversight.
We need to update is_inline before calling get_all_import_attributes to immediately reflect that the outermost import we're processing shall indeed be considered as inline, as it's a glob.
Otherwise, we will end up calling add_without_unwanted_attributes with is_inline == false on the "intermediate" re-exports, which will skip propagating their cfgs.

I believe this fixes #96166, even though the description there is not super clear on the exact test case they used (there's a snippet but the author says their code is actually different).

Refs #43781
@rustbot label +F-doc_cfg
@rustbot r? @GuillaumeGomez

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output. F-doc_cfg `#![feature(doc_cfg)]` labels May 27, 2026
@lcian lcian force-pushed the fix/glob-reexport-feature-combination branch 2 times, most recently from 67eb276 to e1944da Compare May 27, 2026 23:28
@lcian lcian changed the title rustdoc: fix cfg combination for glob reexports rustdoc: correctly propagate cfgs for glob reexports May 27, 2026
@lcian lcian force-pushed the fix/glob-reexport-feature-combination branch from e1944da to 028afca Compare May 28, 2026 07:07
@lcian lcian marked this pull request as ready for review May 28, 2026 08:35
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels May 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

F-doc_cfg `#![feature(doc_cfg)]` S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

doc(cfg) doesn't work on glob reexports

3 participants