Skip to content

bootstrap: Include feature-gated items in bootstrap tool docs - #161900

Open
Zalathar wants to merge 2 commits into
rust-lang:mainfrom
Zalathar:tool-doc
Open

bootstrap: Include feature-gated items in bootstrap tool docs#161900
Zalathar wants to merge 2 commits into
rust-lang:mainfrom
Zalathar:tool-doc

Conversation

@Zalathar

@Zalathar Zalathar commented Aug 28, 2026

Copy link
Copy Markdown
Member

View all comments

I noticed that the nightly-rustc docs for build_helper don't include the metrics module, because it's gated behind the non-default feature flag feature = "metrics".

This PR fixes that by using --all-features to document all features, and enabling rustdoc's #![feature(doc_cfg)] (via -Zcrate-attr) so that rustdoc will indicate which items require feature flags.

The first two commits are a general cleanup of tool_doc! to pull almost all of its non-trivial code out of the macro and into regular functions.

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 28, 2026
@rustbot rustbot added the T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) label Aug 28, 2026
@rustbot

rustbot commented Aug 28, 2026

Copy link
Copy Markdown
Collaborator

r? @Mark-Simulacrum

rustbot has assigned @Mark-Simulacrum.
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: bootstrap
  • bootstrap expanded to 6 candidates
  • Random selection from Mark-Simulacrum, clubby789

@Zalathar

Copy link
Copy Markdown
Member Author

As a follow-up we could also enable this for compiler crates, since a few of them have feature flags to enable nightly-only features when they aren't being used by rust-analyzer.

@Zalathar

Copy link
Copy Markdown
Member Author

I would also like to note that this would have been much more annoying without -Zcrate-attr.

@rust-log-analyzer

This comment has been minimized.

@Zalathar

Copy link
Copy Markdown
Member Author

I really want to blanket allow clippy::too_many_arguments and clippy::type_complexity across all of bootstrap, but I won't do that in this PR.

@Kobzol

Kobzol commented Aug 28, 2026

Copy link
Copy Markdown
Member

r? kobzol

Note that this will conflict a lot with #161716. In general I'm happy to see most of the code move out of a macro.

@rustbot rustbot assigned Kobzol and unassigned Mark-Simulacrum Aug 28, 2026
@Kobzol

Kobzol commented Aug 28, 2026

Copy link
Copy Markdown
Member

Aside: do you find the build_helper/bootstrap docs being present in the nightly rustc docs useful?

@Zalathar

Copy link
Copy Markdown
Member Author

Aside: do you find the build_helper/bootstrap docs being present in the nightly rustc docs useful?

I use the nightly-rustc docs intermittently, but when I do reach for them it's nice to have everything there in one place, especially when I'm not at a computer and can't easily search the source.

@Zalathar

Copy link
Copy Markdown
Member Author

Note that this will conflict a lot with #161716. In general I'm happy to see most of the code move out of a macro.

If conflicts are a concern, I can potentially cut this PR down to just the main fix (within the macro), and defer the macro-extraction to follow-up work.

(I had to do the extraction to work on the fix, but now that I have the fix it should be easy to backport to main.)

@Kobzol

Kobzol commented Aug 28, 2026

Copy link
Copy Markdown
Member

I'd perhaps either do that, or wait for the other PR to get merged, yeah.

@Zalathar

Zalathar commented Sep 2, 2026

Copy link
Copy Markdown
Member Author

@rustbot blocked (on #161716 to avoid conflicts)

@rustbot rustbot added S-blocked Status: Blocked on something else such as an RFC or other implementation work. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 2, 2026
@rust-bors

This comment has been minimized.

@rustbot

rustbot commented Sep 4, 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.

@Zalathar

Zalathar commented Sep 4, 2026

Copy link
Copy Markdown
Member Author

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-blocked Status: Blocked on something else such as an RFC or other implementation work. labels Sep 4, 2026
@Kobzol

Kobzol commented Sep 4, 2026

Copy link
Copy Markdown
Member

Looks good, thanks! Feel free to r=me once PR CI is green.

@Zalathar

Zalathar commented Sep 4, 2026

Copy link
Copy Markdown
Member Author

PR CI is green.

@bors r=Kobzol

@rust-bors

rust-bors Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 8f1843d has been approved by Kobzol

It is now in the queue for this repository.

@rust-bors rust-bors Bot added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Sep 4, 2026
@rust-bors rust-bors Bot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 4, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Sep 4, 2026
bootstrap: Include feature-gated items in bootstrap tool docs

I noticed that the [nightly-rustc docs for `build_helper`](https://doc.rust-lang.org/nightly/nightly-rustc/build_helper/index.html) don't include the `metrics` module, because it's gated behind the non-default feature flag `feature = "metrics"`.

This PR fixes that by using `--all-features` to document all features, and enabling rustdoc's `#![feature(doc_cfg)]` [(via -`Zcrate-attr`)](rust-lang#138287) so that rustdoc will indicate which items require feature flags.

The first two commits are a general cleanup of `tool_doc!` to pull almost all of its non-trivial code out of the macro and into regular functions.
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Sep 4, 2026
bootstrap: Include feature-gated items in bootstrap tool docs

I noticed that the [nightly-rustc docs for `build_helper`](https://doc.rust-lang.org/nightly/nightly-rustc/build_helper/index.html) don't include the `metrics` module, because it's gated behind the non-default feature flag `feature = "metrics"`.

This PR fixes that by using `--all-features` to document all features, and enabling rustdoc's `#![feature(doc_cfg)]` [(via -`Zcrate-attr`)](rust-lang#138287) so that rustdoc will indicate which items require feature flags.

The first two commits are a general cleanup of `tool_doc!` to pull almost all of its non-trivial code out of the macro and into regular functions.
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Sep 4, 2026
bootstrap: Include feature-gated items in bootstrap tool docs

I noticed that the [nightly-rustc docs for `build_helper`](https://doc.rust-lang.org/nightly/nightly-rustc/build_helper/index.html) don't include the `metrics` module, because it's gated behind the non-default feature flag `feature = "metrics"`.

This PR fixes that by using `--all-features` to document all features, and enabling rustdoc's `#![feature(doc_cfg)]` [(via -`Zcrate-attr`)](rust-lang#138287) so that rustdoc will indicate which items require feature flags.

The first two commits are a general cleanup of `tool_doc!` to pull almost all of its non-trivial code out of the macro and into regular functions.
rust-bors Bot pushed a commit that referenced this pull request Sep 4, 2026
Rollup of 25 pull requests

Successful merges:

 - #159074 ([PAC] FnAbi, llvm.ptrauth.resign and Session API change (2/8))
 - #159792 (A more readable debug map for IndexMaps)
 - #161895 (std::sys::pal::sgx: fix mismatched alloc/free alignment)
 - #161900 (bootstrap: Include feature-gated items in bootstrap tool docs)
 - #161940 (Promote `wasm32-wasip3` to a tier 2 target)
 - #162072 (Add new Tier-3 target: `powerpc64-sony-ps3`)
 - #162179 (type system const items via direct rhs)
 - #162277 (Introduce `rustc_middle::middel::resolve`)
 - #162285 (box: fixup map/try_map deallocate calls)
 - #162286 (string: don't unwind prematurely)
 - #162289 (alloc: a bunch of safety comments)
 - #162292 (Update `askama` version to `0.16.1`)
 - #160509 (Remove `RegionExt`; move methods to `Region` in `rustc_type_ir`)
 - #160906 (Suggest usize instead of placeholder type for array length constants)
 - #160936 (traits: Represent live alias arguments as bitsets)
 - #161400 (Improve diagnostics for references to closures)
 - #161656 (Suggest mutable references for FnMut closure arguments)
 - #161711 (Add more splat fn type tests)
 - #161786 (Make `tcx.def_id_partial_cmp` public)
 - #161953 (sanitizers: Implicitly disable mutually exclusive sanitizers)
 - #162155 (add suggestion for `rustc_allowed_through_unstable_modules` attribute)
 - #162212 (Implement `Rng` for `Box`)
 - #162246 (Fix incorrect meta span)
 - #162266 (std: fix typo)
 - #162291 (Add regression test from 1.98.1)
@GuillaumeGomez

Copy link
Copy Markdown
Member

I think it's the one which broke in #162298 (comment).

Lot of errors like:

error[E0725]: the feature `rustc_private` is not in the list of allowed features
 --> /rustc/cce05538c14655b12f69e264c494b616bf3eff7c/src/tools/rustfmt/src/lib.rs:1:12
  |
1 | #![feature(rustc_private)]
  |            ^^^^^^^^^^^^^

@bors r-

@rust-bors rust-bors Bot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Sep 4, 2026
@rust-bors

rust-bors Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

This pull request was unapproved.

This PR was contained in a rollup (#162298), which was unapproved.

View changes since this unapproval

@Zalathar

Zalathar commented Sep 4, 2026

Copy link
Copy Markdown
Member Author

@bors try jobs=dist-x86_64-linux-alt

rust-bors Bot pushed a commit that referenced this pull request Sep 4, 2026
bootstrap: Include feature-gated items in bootstrap tool docs


try-job: dist-x86_64-linux-alt
@rust-bors

rust-bors Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

⌛ Trying commit 8f1843d with merge 93dc89f

To cancel the try build, run the command @bors try cancel.

Workflow: https://github.com/rust-lang/rust/actions/runs/33890102370


// Tell rustdoc to document which items require feature flags.
cargo.arg("--all-features");
cargo.allow_features("doc_cfg");

@Zalathar Zalathar Sep 4, 2026

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.

Ah, the problem is that if a tool_doc! entry doesn't specify a list of allowed features, then this line has the side-effect of disallowing all features other than doc_cfg.

View changes since the review

This sets `--all-features` when documenting bootstrap tool crates, and enables
rustdoc's `#![feature(doc_cfg)]` to display which items are feature-gated.
@Zalathar

Zalathar commented Sep 4, 2026

Copy link
Copy Markdown
Member Author

@bors try cancel
@bors try jobs=dist-x86_64-linux-alt

@rust-bors

rust-bors Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Try build cancelled. Cancelled workflows:

Hint: if you want to run another try build, you do not need to manually cancel the previous one. Just run @bors try and bors will cancel the previous build automatically.

@rust-bors

rust-bors Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

⌛ Trying commit 8f4106c with merge ca57196

To cancel the try build, run the command @bors try cancel.

Workflow: https://github.com/rust-lang/rust/actions/runs/33891566707

rust-bors Bot pushed a commit that referenced this pull request Sep 4, 2026
bootstrap: Include feature-gated items in bootstrap tool docs


try-job: dist-x86_64-linux-alt
@rust-bors

rust-bors Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

💥 Test timed out after 21600s

@Zalathar

Zalathar commented Sep 4, 2026

Copy link
Copy Markdown
Member Author

@bors try jobs=dist-x86_64-linux-alt

@rust-bors

rust-bors Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

⌛ Trying commit 8f4106c with merge 67e4f70

To cancel the try build, run the command @bors try cancel.

Workflow: https://github.com/rust-lang/rust/actions/runs/33929355839

rust-bors Bot pushed a commit that referenced this pull request Sep 4, 2026
bootstrap: Include feature-gated items in bootstrap tool docs


try-job: dist-x86_64-linux-alt
@rust-bors

rust-bors Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

💥 Test timed out after 21600s

@Zalathar

Zalathar commented Sep 5, 2026

Copy link
Copy Markdown
Member Author

Weird that this keeps happening.

@bors try jobs=dist-x86_64-linux-alt

@rust-bors

rust-bors Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

⌛ Trying commit 8f4106c with merge 3ec43f9

To cancel the try build, run the command @bors try cancel.

Workflow: https://github.com/rust-lang/rust/actions/runs/33947733260

rust-bors Bot pushed a commit that referenced this pull request Sep 5, 2026
bootstrap: Include feature-gated items in bootstrap tool docs


try-job: dist-x86_64-linux-alt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants