Skip to content

Commit 75fb56f

Browse files
committed
Auto merge of rust-lang#40448 - ollie27:rustbuild_docs_compiler, r=alexcrichton
rustbuild: Fix compiler docs * Make sure std docs are generated before compiler docs so rustdoc uses relative links. * Don't document the rustc and rustdoc binary crates as they overwrite the real rustc and rustdoc crates. Fixes rust-lang#40217 r? @alexcrichton
2 parents 824c9eb + 0e0bac9 commit 75fb56f

File tree

2 files changed

+23
-15
lines changed

2 files changed

+23
-15
lines changed

src/bootstrap/doc.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,7 @@ pub fn std(build: &Build, stage: u32, target: &str) {
168168
// We don't want to build docs for internal std dependencies unless
169169
// in compiler-docs mode. When not in that mode, we whitelist the crates
170170
// for which docs must be built.
171-
if build.config.compiler_docs {
172-
cargo.arg("-p").arg("std");
173-
} else {
171+
if !build.config.compiler_docs {
174172
cargo.arg("--no-deps");
175173
for krate in &["alloc", "collections", "core", "std", "std_unicode"] {
176174
cargo.arg("-p").arg(krate);
@@ -244,9 +242,15 @@ pub fn rustc(build: &Build, stage: u32, target: &str) {
244242
.arg(build.src.join("src/rustc/Cargo.toml"))
245243
.arg("--features").arg(build.rustc_features());
246244

247-
// Like with libstd above if compiler docs aren't enabled then we're not
248-
// documenting internal dependencies, so we have a whitelist.
249-
if !build.config.compiler_docs {
245+
if build.config.compiler_docs {
246+
// src/rustc/Cargo.toml contains bin crates called rustc and rustdoc
247+
// which would otherwise overwrite the docs for the real rustc and
248+
// rustdoc lib crates.
249+
cargo.arg("-p").arg("rustc_driver")
250+
.arg("-p").arg("rustdoc");
251+
} else {
252+
// Like with libstd above if compiler docs aren't enabled then we're not
253+
// documenting internal dependencies, so we have a whitelist.
250254
cargo.arg("--no-deps");
251255
for krate in &["proc_macro"] {
252256
cargo.arg("-p").arg(krate);

src/bootstrap/step.rs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -633,12 +633,16 @@ pub fn build_rules<'a>(build: &'a Build) -> Rules {
633633
for (krate, path, default) in krates("test") {
634634
rules.doc(&krate.doc_step, path)
635635
.dep(|s| s.name("libtest-link"))
636+
// Needed so rustdoc generates relative links to std.
637+
.dep(|s| s.name("doc-crate-std"))
636638
.default(default && build.config.compiler_docs)
637639
.run(move |s| doc::test(build, s.stage, s.target));
638640
}
639641
for (krate, path, default) in krates("rustc-main") {
640642
rules.doc(&krate.doc_step, path)
641643
.dep(|s| s.name("librustc-link"))
644+
// Needed so rustdoc generates relative links to std.
645+
.dep(|s| s.name("doc-crate-std"))
642646
.host(true)
643647
.default(default && build.config.docs)
644648
.run(move |s| doc::rustc(build, s.stage, s.target));
@@ -1213,31 +1217,31 @@ mod tests {
12131217
name: "std".to_string(),
12141218
deps: Vec::new(),
12151219
path: cwd.join("src/std"),
1216-
doc_step: "doc-std".to_string(),
1220+
doc_step: "doc-crate-std".to_string(),
12171221
build_step: "build-crate-std".to_string(),
1218-
test_step: "test-std".to_string(),
1219-
bench_step: "bench-std".to_string(),
1222+
test_step: "test-crate-std".to_string(),
1223+
bench_step: "bench-crate-std".to_string(),
12201224
version: String::new(),
12211225
});
12221226
build.crates.insert("test".to_string(), ::Crate {
12231227
name: "test".to_string(),
12241228
deps: Vec::new(),
12251229
path: cwd.join("src/test"),
1226-
doc_step: "doc-test".to_string(),
1230+
doc_step: "doc-crate-test".to_string(),
12271231
build_step: "build-crate-test".to_string(),
1228-
test_step: "test-test".to_string(),
1229-
bench_step: "bench-test".to_string(),
1232+
test_step: "test-crate-test".to_string(),
1233+
bench_step: "bench-crate-test".to_string(),
12301234
version: String::new(),
12311235
});
12321236
build.crates.insert("rustc-main".to_string(), ::Crate {
12331237
name: "rustc-main".to_string(),
12341238
deps: Vec::new(),
12351239
version: String::new(),
12361240
path: cwd.join("src/rustc-main"),
1237-
doc_step: "doc-rustc-main".to_string(),
1241+
doc_step: "doc-crate-rustc-main".to_string(),
12381242
build_step: "build-crate-rustc-main".to_string(),
1239-
test_step: "test-rustc-main".to_string(),
1240-
bench_step: "bench-rustc-main".to_string(),
1243+
test_step: "test-crate-rustc-main".to_string(),
1244+
bench_step: "bench-crate-rustc-main".to_string(),
12411245
});
12421246
return build
12431247
}

0 commit comments

Comments
 (0)