Skip to content

Commit 79f49f3

Browse files
Kobzollcnr
authored andcommitted
Explicitly pass path to built stdlib JSON docs and use the correct compiler for it
1 parent 04cca62 commit 79f49f3

File tree

3 files changed

+26
-23
lines changed

3 files changed

+26
-23
lines changed

src/bootstrap/src/core/build_steps/dist.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ impl Step for JsonDocs {
115115
/// Builds the `rust-docs-json` installer component.
116116
fn run(self, builder: &Builder<'_>) -> Option<GeneratedTarball> {
117117
let target = self.target;
118-
builder.ensure(crate::core::build_steps::doc::Std::from_build_compiler(
118+
let directory = builder.ensure(crate::core::build_steps::doc::Std::from_build_compiler(
119119
self.build_compiler,
120120
target,
121121
DocumentationFormat::Json,
@@ -126,7 +126,7 @@ impl Step for JsonDocs {
126126
let mut tarball = Tarball::new(builder, "rust-docs-json", &target.triple);
127127
tarball.set_product_name("Rust Documentation In JSON Format");
128128
tarball.is_preview(true);
129-
tarball.add_bulk_dir(builder.json_doc_out(target), dest);
129+
tarball.add_bulk_dir(directory, dest);
130130
Some(tarball.generate())
131131
}
132132
}
@@ -1589,19 +1589,21 @@ impl Step for Extended {
15891589
};
15901590
}
15911591

1592+
let target_compiler = builder.compiler(stage, target);
15921593
// When rust-std package split from rustc, we needed to ensure that during
15931594
// upgrades rustc was upgraded before rust-std. To avoid rustc clobbering
15941595
// the std files during uninstall. To do this ensure that rustc comes
15951596
// before rust-std in the list below.
1596-
tarballs.push(builder.ensure(Rustc { compiler: builder.compiler(stage, target) }));
1597+
tarballs.push(builder.ensure(Rustc { compiler: target_compiler }));
15971598
tarballs.push(builder.ensure(Std { compiler, target }).expect("missing std"));
15981599

15991600
if target.is_windows_gnu() {
16001601
tarballs.push(builder.ensure(Mingw { host: target }).expect("missing mingw"));
16011602
}
16021603

16031604
add_component!("rust-docs" => Docs { host: target });
1604-
add_component!("rust-json-docs" => JsonDocs { build_compiler: compiler, target });
1605+
// Std stage N is documented with compiler stage N
1606+
add_component!("rust-json-docs" => JsonDocs { build_compiler: target_compiler, target });
16051607
add_component!("cargo" => Cargo { build_compiler: compiler, target });
16061608
add_component!("rustfmt" => Rustfmt { build_compiler: compiler, target });
16071609
add_component!("rust-analyzer" => RustAnalyzer { build_compiler: compiler, target });

src/bootstrap/src/core/build_steps/doc.rs

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,9 @@ impl Std {
599599
}
600600

601601
impl Step for Std {
602-
type Output = ();
602+
/// Path to a directory with the built documentation.
603+
type Output = PathBuf;
604+
603605
const DEFAULT: bool = true;
604606

605607
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
@@ -629,7 +631,7 @@ impl Step for Std {
629631
///
630632
/// This will generate all documentation for the standard library and its
631633
/// dependencies. This is largely just a wrapper around `cargo doc`.
632-
fn run(self, builder: &Builder<'_>) {
634+
fn run(self, builder: &Builder<'_>) -> Self::Output {
633635
let target = self.target;
634636
let crates = if self.crates.is_empty() {
635637
builder
@@ -673,24 +675,24 @@ impl Step for Std {
673675

674676
doc_std(builder, self.format, self.build_compiler, target, &out, &extra_args, &crates);
675677

676-
// Don't open if the format is json
677-
if let DocumentationFormat::Json = self.format {
678-
return;
679-
}
680-
681-
if builder.paths.iter().any(|path| path.ends_with("library")) {
682-
// For `x.py doc library --open`, open `std` by default.
683-
let index = out.join("std").join("index.html");
684-
builder.open_in_browser(index);
685-
} else {
686-
for requested_crate in crates {
687-
if STD_PUBLIC_CRATES.iter().any(|&k| k == requested_crate) {
688-
let index = out.join(requested_crate).join("index.html");
689-
builder.open_in_browser(index);
690-
break;
678+
// Open if the format is HTML
679+
if let DocumentationFormat::Html = self.format {
680+
if builder.paths.iter().any(|path| path.ends_with("library")) {
681+
// For `x.py doc library --open`, open `std` by default.
682+
let index = out.join("std").join("index.html");
683+
builder.open_in_browser(index);
684+
} else {
685+
for requested_crate in crates {
686+
if STD_PUBLIC_CRATES.iter().any(|&k| k == requested_crate) {
687+
let index = out.join(requested_crate).join("index.html");
688+
builder.open_in_browser(index);
689+
break;
690+
}
691691
}
692692
}
693693
}
694+
695+
out
694696
}
695697

696698
fn metadata(&self) -> Option<StepMetadata> {

src/bootstrap/src/core/builder/tests.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1128,7 +1128,6 @@ mod snapshot {
11281128
[build] rustc 1 <host> -> cargo-clippy 2 <host>
11291129
[build] rustc 1 <host> -> miri 2 <host>
11301130
[build] rustc 1 <host> -> cargo-miri 2 <host>
1131-
[doc] rustc 1 <host> -> std 1 <host> crates=[]
11321131
");
11331132
}
11341133

@@ -1452,7 +1451,7 @@ mod snapshot {
14521451
[build] rustc 1 <host> -> miri 2 <target1>
14531452
[build] rustc 1 <host> -> cargo-miri 2 <target1>
14541453
[build] rustc 1 <host> -> LlvmBitcodeLinker 2 <target1>
1455-
[doc] rustc 1 <host> -> std 1 <target1> crates=[]
1454+
[doc] rustc 2 <target1> -> std 2 <target1> crates=[]
14561455
");
14571456
}
14581457

0 commit comments

Comments
 (0)