about summary refs log tree commit diff
path: root/src/bootstrap
diff options
context:
space:
mode:
authorJakub Beránek <berykubik@gmail.com>2025-08-10 16:32:40 +0200
committerJakub Beránek <berykubik@gmail.com>2025-08-10 16:35:56 +0200
commit8b4d9411bacf46fcdd47c8613dee9b4ebe3a1cdf (patch)
tree566e0e5f7f414a94d01b3c2ed8cb6699facfc742 /src/bootstrap
parent8d53418bd4648e738a0d9b03570d0f66fe24415c (diff)
downloadrust-8b4d9411bacf46fcdd47c8613dee9b4ebe3a1cdf.tar.gz
rust-8b4d9411bacf46fcdd47c8613dee9b4ebe3a1cdf.zip
Explicitly pass path to built stdlib JSON docs and use the correct compiler for it
Diffstat (limited to 'src/bootstrap')
-rw-r--r--src/bootstrap/src/core/build_steps/dist.rs10
-rw-r--r--src/bootstrap/src/core/build_steps/doc.rs36
-rw-r--r--src/bootstrap/src/core/builder/tests.rs3
3 files changed, 26 insertions, 23 deletions
diff --git a/src/bootstrap/src/core/build_steps/dist.rs b/src/bootstrap/src/core/build_steps/dist.rs
index f8393d87014..c2f46e66c3f 100644
--- a/src/bootstrap/src/core/build_steps/dist.rs
+++ b/src/bootstrap/src/core/build_steps/dist.rs
@@ -115,7 +115,7 @@ impl Step for JsonDocs {
     /// Builds the `rust-docs-json` installer component.
     fn run(self, builder: &Builder<'_>) -> Option<GeneratedTarball> {
         let target = self.target;
-        builder.ensure(crate::core::build_steps::doc::Std::from_build_compiler(
+        let directory = builder.ensure(crate::core::build_steps::doc::Std::from_build_compiler(
             self.build_compiler,
             target,
             DocumentationFormat::Json,
@@ -126,7 +126,7 @@ impl Step for JsonDocs {
         let mut tarball = Tarball::new(builder, "rust-docs-json", &target.triple);
         tarball.set_product_name("Rust Documentation In JSON Format");
         tarball.is_preview(true);
-        tarball.add_bulk_dir(builder.json_doc_out(target), dest);
+        tarball.add_bulk_dir(directory, dest);
         Some(tarball.generate())
     }
 }
@@ -1575,11 +1575,12 @@ impl Step for Extended {
             };
         }
 
+        let target_compiler = builder.compiler(stage, target);
         // When rust-std package split from rustc, we needed to ensure that during
         // upgrades rustc was upgraded before rust-std. To avoid rustc clobbering
         // the std files during uninstall. To do this ensure that rustc comes
         // before rust-std in the list below.
-        tarballs.push(builder.ensure(Rustc { compiler: builder.compiler(stage, target) }));
+        tarballs.push(builder.ensure(Rustc { compiler: target_compiler }));
         tarballs.push(builder.ensure(Std { compiler, target }).expect("missing std"));
 
         if target.is_windows_gnu() {
@@ -1587,7 +1588,8 @@ impl Step for Extended {
         }
 
         add_component!("rust-docs" => Docs { host: target });
-        add_component!("rust-json-docs" => JsonDocs { build_compiler: compiler, target });
+        // Std stage N is documented with compiler stage N
+        add_component!("rust-json-docs" => JsonDocs { build_compiler: target_compiler, target });
         add_component!("cargo" => Cargo { build_compiler: compiler, target });
         add_component!("rustfmt" => Rustfmt { build_compiler: compiler, target });
         add_component!("rust-analyzer" => RustAnalyzer { build_compiler: compiler, target });
diff --git a/src/bootstrap/src/core/build_steps/doc.rs b/src/bootstrap/src/core/build_steps/doc.rs
index 28a764dc8ba..ca7a6dc8e07 100644
--- a/src/bootstrap/src/core/build_steps/doc.rs
+++ b/src/bootstrap/src/core/build_steps/doc.rs
@@ -599,7 +599,9 @@ impl Std {
 }
 
 impl Step for Std {
-    type Output = ();
+    /// Path to a directory with the built documentation.
+    type Output = PathBuf;
+
     const DEFAULT: bool = true;
 
     fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
@@ -629,7 +631,7 @@ impl Step for Std {
     ///
     /// This will generate all documentation for the standard library and its
     /// dependencies. This is largely just a wrapper around `cargo doc`.
-    fn run(self, builder: &Builder<'_>) {
+    fn run(self, builder: &Builder<'_>) -> Self::Output {
         let target = self.target;
         let crates = if self.crates.is_empty() {
             builder
@@ -673,24 +675,24 @@ impl Step for Std {
 
         doc_std(builder, self.format, self.build_compiler, target, &out, &extra_args, &crates);
 
-        // Don't open if the format is json
-        if let DocumentationFormat::Json = self.format {
-            return;
-        }
-
-        if builder.paths.iter().any(|path| path.ends_with("library")) {
-            // For `x.py doc library --open`, open `std` by default.
-            let index = out.join("std").join("index.html");
-            builder.open_in_browser(index);
-        } else {
-            for requested_crate in crates {
-                if STD_PUBLIC_CRATES.iter().any(|&k| k == requested_crate) {
-                    let index = out.join(requested_crate).join("index.html");
-                    builder.open_in_browser(index);
-                    break;
+        // Open if the format is HTML
+        if let DocumentationFormat::Html = self.format {
+            if builder.paths.iter().any(|path| path.ends_with("library")) {
+                // For `x.py doc library --open`, open `std` by default.
+                let index = out.join("std").join("index.html");
+                builder.open_in_browser(index);
+            } else {
+                for requested_crate in crates {
+                    if STD_PUBLIC_CRATES.iter().any(|&k| k == requested_crate) {
+                        let index = out.join(requested_crate).join("index.html");
+                        builder.open_in_browser(index);
+                        break;
+                    }
                 }
             }
         }
+
+        out
     }
 
     fn metadata(&self) -> Option<StepMetadata> {
diff --git a/src/bootstrap/src/core/builder/tests.rs b/src/bootstrap/src/core/builder/tests.rs
index b60ca5f428f..32d191c4265 100644
--- a/src/bootstrap/src/core/builder/tests.rs
+++ b/src/bootstrap/src/core/builder/tests.rs
@@ -1128,7 +1128,6 @@ mod snapshot {
         [build] rustc 1 <host> -> cargo-clippy 2 <host>
         [build] rustc 1 <host> -> miri 2 <host>
         [build] rustc 1 <host> -> cargo-miri 2 <host>
-        [doc] rustc 1 <host> -> std 1 <host> crates=[]
         ");
     }
 
@@ -1452,7 +1451,7 @@ mod snapshot {
         [build] rustc 1 <host> -> miri 2 <target1>
         [build] rustc 1 <host> -> cargo-miri 2 <target1>
         [build] rustc 1 <host> -> LlvmBitcodeLinker 2 <target1>
-        [doc] rustc 1 <host> -> std 1 <target1> crates=[]
+        [doc] rustc 2 <target1> -> std 2 <target1> crates=[]
         ");
     }