Repository navigation
Description
Summary
RFC: rust-lang/rfcs#3662 (rustdoc focused)
rust-lang/rust issue: rust-lang/rust#130676
Implementation: #16167, #16309
Documentation: https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#rustdoc-mergeable-info
Leverage rustdoc's mergeable crate info, so that cargo doc can merge cross-crate information (like the search index, source files index) from separate output directories, run rustdoc in parallel, and avoid (sometimes) unexpected documentation merge.
Unresolved Issues
-
cargo cleansupport -
It would be a breaking change, asit is now additivecargo docalready exposes the legacyrustdoc --merge=sharedbehavior (rustdoc artifacts are additive) - Should
rustdoc --merge=finalizebe modeled in Cargo's "unit of execution" model (a.k.a. build graph)- Currently in Cargo, a unit in the unit graph is tied to a Command execution, for example rustc or rustdoc.
rustdoc --merge=finializeis apparently a "unit of execution". However, the currentUnitstruct is designed for compiler invocation, which havefeatures,rustflagsand Cargo target information. If we don't model this invocation in unit of work model, a special rebuild detection mechanism may need to be implemented. It might be worth a refactor if we want to support both this and Support -Zno-link #9019, and perhaps doctest execution in the future.
- Currently in Cargo, a unit in the unit graph is tied to a Command execution, for example rustc or rustdoc.
- Race condition between the build holding the build-dir/target-dir locks and the merge step re-acquiring those locks, feat: support for rustdoc mergeable cross-crate info #16309 (comment) (would be resolved if merge was in the unit graph)
- Targets are merged serially, feat: support for rustdoc mergeable cross-crate info #16309 (comment) (would be resolved if merge was in the unit graph)
- Should all
RUSTDOCFLAGSapply torustdoc --merge=finalizecall?- Some probably only need to pass to the
--merge=finalizeinvocation, like--extend-css? - See fix: Pass rustdoc flags to final CCI merge step #17269 (comment). Basically rustdoc expect most of flags pass to all invociation including merge/finalize invocation. Rustdoc will ignore those not supported.
- Some probably only need to pass to the
- rustdoc ICE when building different workspace member in the same workspace
- feat: support for rustdoc mergeable cross-crate info #16309 (comment)
- Maybe be a rustdoc bug. Putting it here for awareness, since it blocks the stabilization on Cargo side.
- Fixed by rustdoc: fix bugs with search aliases and merging rust#149700
Future Extensions
- Ability to turn off
cargo docinvocations from being additive- If Cargo provides a flag, say
--config doc.merge=on|off, how to deal with that user switching betweendoc.merge=offanddoc.merge=on? Should the pre-existing HTML file be kept or removed?
- If Cargo provides a flag, say
- crate-info JSON file name collision. Same as below
About tracking issues
Tracking issues are used to record the overall progress of implementation.
They are also used as hubs connecting to other relevant issues, e.g., bugs or open design questions.
A tracking issue is however not meant for large scale discussion, questions, or bug reports about a feature.
Instead, open a dedicated issue for the specific matter and add the relevant feature gate label.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsNo status
Activity
feat: support for rustdoc mergeable cross-crate info (#16309)
ranger-ross commentedon Jan 18, 2026
In the current implementation,
-Zrustdoc-mergeable-infoonly supports the newbuild-dirlayout.However, its possible to run it using the old layout and get a broken
target.I think
-Zrustdoc-mergeable-infoshould implicitly enable-Zbuild-dir-new-layoutin the same way that-Zfine-grain-lockingdoes.cargo/src/cargo/core/features.rs
Lines 1529 to 1534 in a793cd1
tools: document arch/chips crates against their real targets, merge i…
tools: document arch/chips crates against their real targets, merge i…
tools: document arch/chips crates against their real targets, merge i…
tools: document arch/chips crates against their real targets, merge i…
tools: document arch/chips crates against their real targets, merge i…