Skip to content

rustdoc: preserve parent doc cfg for macro_export macros#155954

Open
cijiugechu wants to merge 1 commit intorust-lang:mainfrom
cijiugechu:doc_cfg-decl-macro
Open

rustdoc: preserve parent doc cfg for macro_export macros#155954
cijiugechu wants to merge 1 commit intorust-lang:mainfrom
cijiugechu:doc_cfg-decl-macro

Conversation

@cijiugechu
Copy link
Copy Markdown
Member

@cijiugechu cijiugechu commented Apr 29, 2026

The detached-item context is discovered before propagate_doc_cfg, it is carried on the clean item and consumed by the pass.

Closes #100916

@rustbot rustbot added 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. labels Apr 29, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 29, 2026

r? @notriddle

rustbot has assigned @notriddle.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: rustdoc
  • rustdoc expanded to 9 candidates
  • Random selection from GuillaumeGomez, fmease, lolbinarycat, notriddle


/// This function goes through the attributes list (`new_attrs`) and extracts the attributes that
/// affect the cfg state propagated to detached items.
fn add_cfg_state_attributes(attrs: &mut Vec<Attribute>, new_attrs: &[Attribute]) {
Copy link
Copy Markdown
Member Author

@cijiugechu cijiugechu Apr 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I kept them(this function and add_only_cfg_attributes) separate because a shared helper would make the logic harder to follow.

View changes since the review

@cijiugechu cijiugechu added the F-doc_cfg `#![feature(doc_cfg)]` label Apr 29, 2026
@cijiugechu cijiugechu changed the title rustdoc: preserve parent doc cfg for macro_export macros rustdoc: preserve parent doc cfg for macro_export macros Apr 29, 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.

rustdoc doesn't automatically render the #[cfg]s on decl macros

3 participants