Skip to content

Commit 81bad57

Browse files
notriddleweihanglo
andcommitted
feat(unstable): add -Zrustdoc-mergeable-info
Co-authored-by: Michael Howell <michael@notriddle.com> Co-authored-by: Weihang Lo <me@weihanglo.tw>
1 parent 783ab5c commit 81bad57

File tree

4 files changed

+47
-14
lines changed

4 files changed

+47
-14
lines changed

src/cargo/core/features.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -884,6 +884,7 @@ unstable_cli_options!(
884884
rustc_unicode: bool = ("Enable `rustc`'s unicode error format in Cargo's error messages"),
885885
rustdoc_depinfo: bool = ("Use dep-info files in rustdoc rebuild detection"),
886886
rustdoc_map: bool = ("Allow passing external documentation mappings to rustdoc"),
887+
rustdoc_mergeable_info: bool = ("Use rustdoc mergeable cross-crate-info files"),
887888
rustdoc_scrape_examples: bool = ("Allows Rustdoc to scrape code examples from reverse-dependencies"),
888889
sbom: bool = ("Enable the `sbom` option in build config in .cargo/config.toml file"),
889890
script: bool = ("Enable support for single-file, `.rs` packages"),
@@ -1415,6 +1416,7 @@ impl CliUnstable {
14151416
"rustc-unicode" => self.rustc_unicode = parse_empty(k, v)?,
14161417
"rustdoc-depinfo" => self.rustdoc_depinfo = parse_empty(k, v)?,
14171418
"rustdoc-map" => self.rustdoc_map = parse_empty(k, v)?,
1419+
"rustdoc-mergeable-info" => self.rustdoc_mergeable_info = parse_empty(k, v)?,
14181420
"rustdoc-scrape-examples" => self.rustdoc_scrape_examples = parse_empty(k, v)?,
14191421
"sbom" => self.sbom = parse_empty(k, v)?,
14201422
"section-timings" => self.section_timings = parse_empty(k, v)?,

src/doc/src/reference/unstable.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ Each new feature described below should explain how to use it.
103103
* [scrape-examples](#scrape-examples) --- Shows examples within documentation.
104104
* [output-format](#output-format-for-rustdoc) --- Allows documentation to also be emitted in the experimental [JSON format](https://doc.rust-lang.org/nightly/nightly-rustc/rustdoc_json_types/).
105105
* [rustdoc-depinfo](#rustdoc-depinfo) --- Use dep-info files in rustdoc rebuild detection.
106+
* [rustdoc-mergeable-info](#rustdoc-mergeable-info) --- Use rustdoc mergeable cross-crate-info files.
106107
* `Cargo.toml` extensions
107108
* [Profile `rustflags` option](#profile-rustflags-option) --- Passed directly to rustc.
108109
* [Profile `hint-mostly-unused` option](#profile-hint-mostly-unused-option) --- Hint that a dependency is mostly unused, to optimize compilation time.
@@ -2059,6 +2060,17 @@ cargo +nightly check --compile-time-deps --all-targets -Z unstable-options
20592060

20602061
Enable `rustc`'s unicode error format in Cargo's error messages
20612062

2063+
## rustdoc mergeable info
2064+
2065+
* Original Pull Request: [#16309](https://github.com/rust-lang/cargo/pull/16309)
2066+
* Tracking issue: [#16306](https://github.com/rust-lang/cargo/issues/16306)
2067+
* Tracking rustc issue: [rust-lang/rust#130676](https://github.com/rust-lang/rust/issues/130676)
2068+
2069+
The `-Z rustdoc-mergeable-info` leverage rustdoc's mergeable crate info,
2070+
so that `cargo doc` can merge cross-crate information
2071+
(like the search index, source files index, etc.)
2072+
from separate output directories,
2073+
and run `rustdoc` in parallel.
20622074

20632075
# Stabilized and removed features
20642076

tests/testsuite/cargo/z_help/stdout.term.svg

Lines changed: 16 additions & 14 deletions
Loading

tests/testsuite/doc.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3201,3 +3201,20 @@ fn rebuild_tracks_checksum() {
32013201
let doc_html = p.read_file("target/doc/foo/index.html");
32023202
assert!(doc_html.contains("depinfo-after"));
32033203
}
3204+
3205+
#[cargo_test(nightly, reason = "rustdoc mergeable crate info is unstable")]
3206+
fn mergeable_info_gated() {
3207+
let p = project()
3208+
.file("Cargo.toml", &basic_lib_manifest("foo"))
3209+
.file("src/lib.rs", "")
3210+
.build();
3211+
3212+
p.cargo("doc -Zrustdoc-mergeable-info")
3213+
.with_status(101)
3214+
.with_stderr_data(str![[r#"
3215+
[ERROR] the `-Z` flag is only accepted on the nightly channel of Cargo, but this is the `stable` channel
3216+
See https://doc.rust-lang.org/book/appendix-07-nightly-rust.html for more information about Rust release channels.
3217+
3218+
"#]])
3219+
.run();
3220+
}

0 commit comments

Comments
 (0)