Skip to content

[rustdoc] Do not take doc(cfg()) into account when filtering doctests#159014

Open
GuillaumeGomez wants to merge 3 commits into
rust-lang:mainfrom
GuillaumeGomez:doc-cfg-filter-doctest
Open

[rustdoc] Do not take doc(cfg()) into account when filtering doctests#159014
GuillaumeGomez wants to merge 3 commits into
rust-lang:mainfrom
GuillaumeGomez:doc-cfg-filter-doctest

Conversation

@GuillaumeGomez

@GuillaumeGomez GuillaumeGomez commented Jul 9, 2026

Copy link
Copy Markdown
Member

Part of #147033.

Because it was using the extract_cfg_from_attrs common function, it was taking into account the doc(cfg()) attributes the same as if they were a cfg.

I didn't mark this PR as "fix" because I didn't handle the case of the doctest not being marked as ignored because I'm not sure if we should revisit the fact that we ignore these doctests or if we should just mark them as ignored (because of target_feature(enable = "...")).

Setting @fmease as reviewer as they are likely the only one with context about this issue. 😆

r? @fmease

@rustbot rustbot added A-run-make Area: port run-make Makefiles to rmake.rs S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Jul 9, 2026
@rust-log-analyzer

This comment has been minimized.

@GuillaumeGomez

Copy link
Copy Markdown
Member Author

And now it fails because we (doc) inlined some functions. Fixing that then. :)

@rustbot rustbot added O-wasi Operating system: Wasi, Webassembly System Interface O-wasm Target: WASM (WebAssembly), http://webassembly.org/ O-windows Operating system: Windows labels Jul 9, 2026
@rust-log-analyzer

This comment has been minimized.

@GuillaumeGomez GuillaumeGomez force-pushed the doc-cfg-filter-doctest branch from f5059c8 to 062cfea Compare July 9, 2026 14:58
@rust-log-analyzer

This comment has been minimized.

@GuillaumeGomez GuillaumeGomez force-pushed the doc-cfg-filter-doctest branch from 062cfea to 1d5692c Compare July 9, 2026 15:43
@GuillaumeGomez

Copy link
Copy Markdown
Member Author

Fixed CI \o/

Comment on lines 904 to 910

@fmease fmease Jul 14, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I've only skimmed this function, so I'm wondering whether your added include_doc_cfg: bool parameter also accounts for inherited doc-cfgs. Like, do we still consider the doctest untestable and skip it in the code below?

#![feature(doc_cfg)]

#[doc(cfg(false))]
mod dummy {
    /// ```
    /// ```
    fn f() {}
}

View changes since the review

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Damn, that's a good take. Ok, new approach: writing up a new function and stop using stuff we shouldn't. :)

@GuillaumeGomez GuillaumeGomez force-pushed the doc-cfg-filter-doctest branch from 1d5692c to a0bf3c9 Compare July 15, 2026 13:10
@rustbot

rustbot commented Jul 15, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@GuillaumeGomez

Copy link
Copy Markdown
Member Author

Reverted changes I made to extract_cfg_from_attrs and instead only look for the target_feature attributes.

@rust-log-analyzer

This comment has been minimized.

@GuillaumeGomez

Copy link
Copy Markdown
Member Author

Ah, new stuff gets added.

@GuillaumeGomez GuillaumeGomez force-pushed the doc-cfg-filter-doctest branch from a0bf3c9 to 59a72c3 Compare July 15, 2026 14:50
@rustbot

rustbot commented Jul 15, 2026

Copy link
Copy Markdown
Collaborator

stdarch is developed in its own repository. If possible, consider making this change to rust-lang/stdarch instead.

cc @Amanieu, @folkertdev, @sayantn

@GuillaumeGomez GuillaumeGomez force-pushed the doc-cfg-filter-doctest branch from 59a72c3 to 885af7e Compare July 15, 2026 15:53
@rust-log-analyzer

This comment has been minimized.

@GuillaumeGomez GuillaumeGomez force-pushed the doc-cfg-filter-doctest branch from 885af7e to 21e8051 Compare July 15, 2026 20:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-run-make Area: port run-make Makefiles to rmake.rs O-wasi Operating system: Wasi, Webassembly System Interface O-wasm Target: WASM (WebAssembly), http://webassembly.org/ O-windows Operating system: Windows S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants