Fix, simplify, and document doc meta finalize mode - #159473
Conversation
|
r? @folkertdev rustbot has assigned @folkertdev. Use Why was this reviewer chosen?The reviewer was selected based on:
|
|
r? @camelid |
|
|
Since we're getting rid of the ability to do finalize and document at the same time, we can't actually do this in the rustdoc-html test build system and need to do it this way instead.
Co-authored-by: Noah Lev <37223377+camelid@users.noreply.github.com>
Co-authored-by: Noah Lev <37223377+camelid@users.noreply.github.com>
9e2125b to
d0fec14
Compare
|
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. |
| let config = core::create_config( | ||
| Input::Str { | ||
| name: rustc_span::FileName::Custom(String::new()), | ||
| input: String::new(), | ||
| }, | ||
| options, | ||
| &render_options, | ||
| ); | ||
| return wrap_return( | ||
| dcx, | ||
| rustc_span::create_session_globals_then(options.edition, &[], None, || { | ||
| run_merge_finalize(render_options) | ||
| interface::run_compiler(config, |compiler| { | ||
| run_merge_finalize(render_options, compiler) |
There was a problem hiding this comment.
Ditto here, but getting rid of the fake Input::Str is harder, and this seems less bad than making a fake crate and TyCtxt. So fine to just leave it.
|
We're also missing the root-level |
|
Good catch! settings.html and help.html are moved, so they get generated at finalize now. |
This comment has been minimized.
This comment has been minimized.
23fae6c to
5f940df
Compare
|
Have we specified the behavior of rustdoc when two different invocations use the same |
Good point. I've added a mention of this to the unstable book. |
I asked mostly because I wonder if we should forbid/not support this use case. Otherwise we need to support reading multiple crates' metadata from a single flag's metadata directory. It might force us into adding extra structure to our metadata directories to make sure that different crates' entries don't clash. |
|
Thanks! @bors r+ |
…uwer Rollup of 12 pull requests Successful merges: - #159014 ([rustdoc] Do not take `doc(cfg())` into account when filtering doctests) - #159029 (rustc_llvm: Emit module summaries when using -Clto=fat) - #160574 (Update rustc-perf submodule) - #154585 (treat no_mangle_generic_items as hard error instead of lint warning) - #159473 (Fix, simplify, and document doc meta finalize mode) - #157489 (Add CoerceShared field-wise reborrow WF checks) - #160532 (Add Enzyme bugfix to support rust+llvm23) - #160545 (Reorder the methods in `#[rustc_must_implement_one_of]`) - #160558 (Revert "codegen_ssa: no dbginfo for scalable vec local w/ `-O0`") - #160566 (Re-enable bool indexing assembly test for LLVM 23) - #160569 (Remove `OnDuplicate::Custom`) - #160576 ([rustdoc] Create output file after we checked that the standalone markdown file is valid)
Rollup merge of #159473 - notriddle:rename-parts-to-dep-meta, r=camelid Fix, simplify, and document doc meta finalize mode Follow up #159415 (comment) Get rid of the mode where you can finalize the CCI and generate more docs at the same time. It isn't used in Cargo, and probably won't be used elsewhere? Fixes a bug where the crate index, settings page, and help page aren’t generated at finalize time. Update documentation. Move CCI tests to run-make, so that we can test the finalize step’s CLI.
…uwer Rollup of 12 pull requests Successful merges: - rust-lang/rust#159014 ([rustdoc] Do not take `doc(cfg())` into account when filtering doctests) - rust-lang/rust#159029 (rustc_llvm: Emit module summaries when using -Clto=fat) - rust-lang/rust#160574 (Update rustc-perf submodule) - rust-lang/rust#154585 (treat no_mangle_generic_items as hard error instead of lint warning) - rust-lang/rust#159473 (Fix, simplify, and document doc meta finalize mode) - rust-lang/rust#157489 (Add CoerceShared field-wise reborrow WF checks) - rust-lang/rust#160532 (Add Enzyme bugfix to support rust+llvm23) - rust-lang/rust#160545 (Reorder the methods in `#[rustc_must_implement_one_of]`) - rust-lang/rust#160558 (Revert "codegen_ssa: no dbginfo for scalable vec local w/ `-O0`") - rust-lang/rust#160566 (Re-enable bool indexing assembly test for LLVM 23) - rust-lang/rust#160569 (Remove `OnDuplicate::Custom`) - rust-lang/rust#160576 ([rustdoc] Create output file after we checked that the standalone markdown file is valid)
…uwer Rollup of 12 pull requests Successful merges: - rust-lang/rust#159014 ([rustdoc] Do not take `doc(cfg())` into account when filtering doctests) - rust-lang/rust#159029 (rustc_llvm: Emit module summaries when using -Clto=fat) - rust-lang/rust#160574 (Update rustc-perf submodule) - rust-lang/rust#154585 (treat no_mangle_generic_items as hard error instead of lint warning) - rust-lang/rust#159473 (Fix, simplify, and document doc meta finalize mode) - rust-lang/rust#157489 (Add CoerceShared field-wise reborrow WF checks) - rust-lang/rust#160532 (Add Enzyme bugfix to support rust+llvm23) - rust-lang/rust#160545 (Reorder the methods in `#[rustc_must_implement_one_of]`) - rust-lang/rust#160558 (Revert "codegen_ssa: no dbginfo for scalable vec local w/ `-O0`") - rust-lang/rust#160566 (Re-enable bool indexing assembly test for LLVM 23) - rust-lang/rust#160569 (Remove `OnDuplicate::Custom`) - rust-lang/rust#160576 ([rustdoc] Create output file after we checked that the standalone markdown file is valid)
…red-target crates out rust-lang/rust#159473 (merged 2026-08-06) made passing both --write-doc-meta-dir and --read-doc-meta-dir to one rustdoc invocation a hard error -- exactly what this script's old aggregator step did. Our pinned nightly (2026-07-21) predates that change, so the script still worked, but would break the moment the toolchain pin moves past it. Rewritten as a genuine finalize-only step: a bare `rustdoc` invocation (no cargo, no crate source -- finalize mode doesn't take any anymore) reading every meta directory and writing the merged glue files directly. This also drops the old aggregator's `AGGREGATOR_CRATE`/rebuild-with-a-second-CARGO_TARGET_DIR complexity entirely, since finalize mode has no cargo fingerprint to fight with. Along the way, hit a second issue: on our pinned nightly, finalize mode silently doesn't write help.html/settings.html at all (the exact bug rust-lang/rust#159473 itself describes fixing, but our pin predates the fix). Since those two files are static UI chrome with no crate-specific content, they're now generated via an ordinary, non-merge-mode rustdoc call on a throwaway empty crate instead -- sidesteps the bug on old nightlies and is unaffected by whatever else changes about finalize mode's behavior in the future. Added a comment documenting what we've learned about this feature's stability (tracking issue, stabilization PR status, the two upstream changes that motivated this rewrite, and why cargo's separate -Z rustdoc-mergeable-info automation doesn't apply here), so the next person hitting a break on a toolchain bump has pointers. Also split CRATE_TARGETS into CRATE_TARGETS (one crate, one real target, unambiguous) and SHARED_CRATE_TARGETS (crates whose dependent boards actually build for more than one real target, where picking one is a deliberate, somewhat arbitrary call: riscv/riscv-csr serve both riscv32 and riscv64 boards, cortexm/cortexv7m serve both thumbv7em and thumbv8m.main boards) -- folded back into CRATE_TARGETS before use, so nothing downstream changes. Verified this split is exhaustive: checked every CRATE_TARGETS crate's actual board dependents' .cargo/config.toml target lines; only these four crates resolve to more than one distinct target. Verified: a full `NOWARNINGS=true` doc build on the pinned nightly still produces 169/169 crates, 34/34 static files, correct help.html/settings.html, and a clean cortexm/cortexm33/riscv/x86 MPU trait-impl merge with no duplicates. Additionally verified the finalize step and empty-crate chrome generation against a nightly after rust-lang/rust#159473 (installing riscv32imac-unknown-none-elf/ thumbv7em-none-eabi targets for it) -- same clean merge, confirming this works on both sides of the toolchain change that motivated the rewrite. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018kKWYpBqL9jafD7rtvt9qH
…nto unified docs build_all_docs.sh cross-compiles arch/* and select chips/* crates against their real target triples instead of the host, and merges the results into one unified doc tree using rustdoc's cross-crate-info merging mechanism (RFC 3662, "Mergeable rustdoc cross-crate info": --write-doc-meta-dir/--read-doc-meta-dir, gated behind -Z unstable-options). This lets those crates drop the `doc` half of their cfg gates, since their real (not mocked) implementation gets documented directly. This relies entirely on rustdoc's own merge logic -- the script never parses or rewrites rustdoc's own output format -- but the flags it's built on are still actively changing shape, not close to stabilizing: - rust-lang/rust#130676 is the tracking issue. - rust-lang/rust#152902, the stabilization PR, is S-blocked/needs-fcp. Its FCP was cancelled 2026-07-17 pending interface changes, and T-rustdoc has floated replacing the whole mechanism with info embedded in .rmeta files instead. As of 2026-08-07 the team wants to "dogfood this feature a bit" before reconsidering stabilization. - rust-lang/rust#159415 (merged 2026-07-17) renamed the RFC's original --parts-out-dir / --include-parts-dir / --merge=none|shared|finalize flags to today's --write-doc-meta-dir / --read-doc-meta-dir. - rust-lang/rust#159473 (merged 2026-08-06) removed the mode this script's finalize step would otherwise need (passing both --write-doc-meta-dir and --read-doc-meta-dir to one invocation) -- that combination is a hard error on recent nightlies, and finalize mode (--read-doc-meta-dir) takes no crate source at all. That's why the finalize step below runs bare `rustdoc`, not `cargo rustdoc -p ...`. - Cargo has a separate, less mature automation layer for this (-Z rustdoc-mergeable-info, tracked by rust-lang/cargo#16306) -- not an option here, since it's explicitly same-target-only and this script's whole point is merging docs built for different targets. Expect to revisit this script on future toolchain bumps. CRATE_TARGETS is a plain indexed array of "crate:target-triple" entries (rather than an associative array via `declare -A`) deliberately: macOS ships bash 3.2, which predates associative arrays entirely. Crates whose dependent boards/chips actually build for more than one real target -- where picking one is a deliberate, somewhat arbitrary call rather than a fact about the crate -- are called out separately in SHARED_CRATE_TARGETS and folded into CRATE_TARGETS before use. Verified: run the script locally; diff the set of crates listed in the merged `crates.js` against the previous single-pass build's output -- every crate still appears. Spot-checked that `trait.impl/kernel/platform/mpu/trait.MPU.js` shows implementors from more than one arch crate, confirming cross-crate merging works. Verified against both the pinned nightly and a nightly after rust-lang/rust#159473, installing missing target components as needed, confirming the finalize step works on both sides of that upstream change. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018kKWYpBqL9jafD7rtvt9qH
View all comments
Follow up #159415 (comment)
Get rid of the mode where you can finalize the CCI and generate more docs at the same time. It isn't used in Cargo, and probably won't be used elsewhere?
Fixes a bug where the crate index, settings page, and help page aren’t generated at finalize time.
Update documentation.
Move CCI tests to run-make, so that we can test the finalize step’s CLI.