Skip to content

Commit ec8b07c

Browse files
committed
Rename Builder::rustdoc to Builder::rustdoc_for_compiler
To clarify what it does.
1 parent ab943b0 commit ec8b07c

File tree

8 files changed

+32
-24
lines changed

8 files changed

+32
-24
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ impl Step for Rustc {
425425
.as_ref()
426426
.is_none_or(|tools| tools.iter().any(|tool| tool == "rustdoc"))
427427
{
428-
let rustdoc = builder.rustdoc(compiler);
428+
let rustdoc = builder.rustdoc_for_compiler(compiler);
429429
builder.install(&rustdoc, &image.join("bin"), FileType::Executable);
430430
}
431431

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ impl<P: Step> Step for RustbookSrc<P> {
149149
let mut rustbook_cmd = builder.tool_cmd(Tool::Rustbook);
150150

151151
if let Some(compiler) = self.rustdoc_compiler {
152-
let mut rustdoc = builder.rustdoc(compiler);
152+
let mut rustdoc = builder.rustdoc_for_compiler(compiler);
153153
rustdoc.pop();
154154
let old_path = env::var_os("PATH").unwrap_or_default();
155155
let new_path =
@@ -365,7 +365,7 @@ impl Step for Standalone {
365365
}
366366

367367
let html = out.join(filename).with_extension("html");
368-
let rustdoc = builder.rustdoc(compiler);
368+
let rustdoc = builder.rustdoc_for_compiler(compiler);
369369
if up_to_date(&path, &html)
370370
&& up_to_date(&footer, &html)
371371
&& up_to_date(&favicon, &html)
@@ -463,7 +463,7 @@ impl Step for Releases {
463463
let html = out.join("releases.html");
464464
let tmppath = out.join("releases.md");
465465
let inpath = builder.src.join("RELEASES.md");
466-
let rustdoc = builder.rustdoc(compiler);
466+
let rustdoc = builder.rustdoc_for_compiler(compiler);
467467
if !up_to_date(&inpath, &html)
468468
|| !up_to_date(&footer, &html)
469469
|| !up_to_date(&favicon, &html)

src/bootstrap/src/core/build_steps/perf.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ Consider setting `rust.debuginfo-level = 1` in `bootstrap.toml`."#);
157157
if let Some(opts) = args.cmd.shared_opts()
158158
&& opts.profiles.contains(&Profile::Doc)
159159
{
160-
builder.ensure(Rustdoc { compiler });
160+
builder.ensure(Rustdoc { target_compiler: compiler });
161161
}
162162

163163
let sysroot = builder.ensure(Sysroot::new(compiler));

src/bootstrap/src/core/build_steps/test.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ impl Step for Cargotest {
260260
.arg(&out_dir)
261261
.args(builder.config.test_args())
262262
.env("RUSTC", builder.rustc(compiler))
263-
.env("RUSTDOC", builder.rustdoc(compiler));
263+
.env("RUSTDOC", builder.rustdoc_for_compiler(compiler));
264264
add_rustdoc_cargo_linker_args(
265265
&mut cmd,
266266
builder,
@@ -861,7 +861,7 @@ impl Step for RustdocTheme {
861861
.env("RUSTC_SYSROOT", builder.sysroot(self.compiler))
862862
.env("RUSTDOC_LIBDIR", builder.sysroot_target_libdir(self.compiler, self.compiler.host))
863863
.env("CFG_RELEASE_CHANNEL", &builder.config.channel)
864-
.env("RUSTDOC_REAL", builder.rustdoc(self.compiler))
864+
.env("RUSTDOC_REAL", builder.rustdoc_for_compiler(self.compiler))
865865
.env("RUSTC_BOOTSTRAP", "1");
866866
cmd.args(linker_args(builder, self.compiler.host, LldThreads::No, self.compiler.stage));
867867

@@ -1020,7 +1020,11 @@ impl Step for RustdocGUI {
10201020
let mut cmd = builder.tool_cmd(Tool::RustdocGUITest);
10211021

10221022
let out_dir = builder.test_out(self.target).join("rustdoc-gui");
1023-
build_stamp::clear_if_dirty(builder, &out_dir, &builder.rustdoc(self.compiler));
1023+
build_stamp::clear_if_dirty(
1024+
builder,
1025+
&out_dir,
1026+
&builder.rustdoc_for_compiler(self.compiler),
1027+
);
10241028

10251029
if let Some(src) = builder.config.src.to_str() {
10261030
cmd.arg("--rust-src").arg(src);
@@ -1036,7 +1040,7 @@ impl Step for RustdocGUI {
10361040

10371041
cmd.arg("--jobs").arg(builder.jobs().to_string());
10381042

1039-
cmd.env("RUSTDOC", builder.rustdoc(self.compiler))
1043+
cmd.env("RUSTDOC", builder.rustdoc_for_compiler(self.compiler))
10401044
.env("RUSTC", builder.rustc(self.compiler));
10411045

10421046
add_rustdoc_cargo_linker_args(
@@ -1710,7 +1714,7 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the
17101714
|| mode == "rustdoc-json"
17111715
|| suite == "coverage-run-rustdoc"
17121716
{
1713-
cmd.arg("--rustdoc-path").arg(builder.rustdoc(compiler));
1717+
cmd.arg("--rustdoc-path").arg(builder.rustdoc_for_compiler(compiler));
17141718
}
17151719

17161720
if mode == "rustdoc-json" {
@@ -2224,7 +2228,7 @@ impl BookTest {
22242228

22252229
// mdbook just executes a binary named "rustdoc", so we need to update
22262230
// PATH so that it points to our rustdoc.
2227-
let mut rustdoc_path = builder.rustdoc(compiler);
2231+
let mut rustdoc_path = builder.rustdoc_for_compiler(compiler);
22282232
rustdoc_path.pop();
22292233
let old_path = env::var_os("PATH").unwrap_or_default();
22302234
let new_path = env::join_paths(iter::once(rustdoc_path).chain(env::split_paths(&old_path)))

src/bootstrap/src/core/build_steps/tool.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -723,7 +723,7 @@ impl Step for RemoteTestServer {
723723
pub struct Rustdoc {
724724
/// This should only ever be 0 or 2.
725725
/// We sometimes want to reference the "bootstrap" rustdoc, which is why this option is here.
726-
pub compiler: Compiler,
726+
pub target_compiler: Compiler,
727727
}
728728

729729
impl Step for Rustdoc {
@@ -736,12 +736,13 @@ impl Step for Rustdoc {
736736
}
737737

738738
fn make_run(run: RunConfig<'_>) {
739-
run.builder
740-
.ensure(Rustdoc { compiler: run.builder.compiler(run.builder.top_stage, run.target) });
739+
run.builder.ensure(Rustdoc {
740+
target_compiler: run.builder.compiler(run.builder.top_stage, run.target),
741+
});
741742
}
742743

743744
fn run(self, builder: &Builder<'_>) -> ToolBuildResult {
744-
let target_compiler = self.compiler;
745+
let target_compiler = self.target_compiler;
745746
let target = target_compiler.host;
746747

747748
if target_compiler.stage == 0 {
@@ -838,11 +839,11 @@ impl Step for Rustdoc {
838839

839840
fn metadata(&self) -> Option<StepMetadata> {
840841
Some(
841-
StepMetadata::build("rustdoc", self.compiler.host)
842+
StepMetadata::build("rustdoc", self.target_compiler.host)
842843
// rustdoc is ToolRustc, so stage N rustdoc is built by stage N-1 rustc
843844
// FIXME: make this stage deduction automatic somehow
844845
// FIXME: log the compiler that actually built ToolRustc steps
845-
.stage(self.compiler.stage.saturating_sub(1)),
846+
.stage(self.target_compiler.stage.saturating_sub(1)),
846847
)
847848
}
848849
}

src/bootstrap/src/core/builder/cargo.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ impl Builder<'_> {
508508
}
509509
_ => panic!("doc mode {mode:?} not expected"),
510510
};
511-
let rustdoc = self.rustdoc(compiler);
511+
let rustdoc = self.rustdoc_for_compiler(compiler);
512512
build_stamp::clear_if_dirty(self, &my_out, &rustdoc);
513513
}
514514

@@ -822,7 +822,7 @@ impl Builder<'_> {
822822
}
823823

824824
let rustdoc_path = match cmd_kind {
825-
Kind::Doc | Kind::Test | Kind::MiriTest => self.rustdoc(compiler),
825+
Kind::Doc | Kind::Test | Kind::MiriTest => self.rustdoc_for_compiler(compiler),
826826
_ => PathBuf::from("/path/to/nowhere/rustdoc/not/required"),
827827
};
828828

src/bootstrap/src/core/builder/mod.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1534,8 +1534,11 @@ You have to build a stage1 compiler for `{}` first, and then use it to build a s
15341534
.map(|entry| entry.path())
15351535
}
15361536

1537-
pub fn rustdoc(&self, compiler: Compiler) -> PathBuf {
1538-
self.ensure(tool::Rustdoc { compiler }).tool_path
1537+
/// Returns a path to `Rustdoc` that "belongs" to the `target_compiler`.
1538+
/// It can be either a stage0 rustdoc or a locally built rustdoc that *links* to
1539+
/// `target_compiler`.
1540+
pub fn rustdoc_for_compiler(&self, target_compiler: Compiler) -> PathBuf {
1541+
self.ensure(tool::Rustdoc { target_compiler }).tool_path
15391542
}
15401543

15411544
pub fn cargo_clippy_cmd(&self, run_compiler: Compiler) -> BootstrapCommand {
@@ -1595,7 +1598,7 @@ You have to build a stage1 compiler for `{}` first, and then use it to build a s
15951598
// equivalently to rustc.
15961599
.env("RUSTDOC_LIBDIR", self.rustc_libdir(compiler))
15971600
.env("CFG_RELEASE_CHANNEL", &self.config.channel)
1598-
.env("RUSTDOC_REAL", self.rustdoc(compiler))
1601+
.env("RUSTDOC_REAL", self.rustdoc_for_compiler(compiler))
15991602
.env("RUSTC_BOOTSTRAP", "1");
16001603

16011604
cmd.arg("-Wrustdoc::invalid_codeblock_attributes");

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ mod defaults {
284284
// not the one it was built by.
285285
assert_eq!(
286286
first(cache.all::<tool::Rustdoc>()),
287-
&[tool::Rustdoc { compiler: Compiler::new(1, a) },]
287+
&[tool::Rustdoc { target_compiler: Compiler::new(1, a) },]
288288
);
289289
}
290290
}
@@ -341,7 +341,7 @@ mod dist {
341341
// stage minus 1 if --stage is not 0. Very confusing!
342342
assert_eq!(
343343
first(builder.cache.all::<tool::Rustdoc>()),
344-
&[tool::Rustdoc { compiler: Compiler::new(2, a) },]
344+
&[tool::Rustdoc { target_compiler: Compiler::new(2, a) },]
345345
);
346346
}
347347
}

0 commit comments

Comments
 (0)