Skip to content

Commit b14ff77

Browse files
committed
Remove temporary BootstrapCommand trait impls
1 parent a34d0a8 commit b14ff77

File tree

9 files changed

+114
-143
lines changed

9 files changed

+114
-143
lines changed

src/bootstrap/src/core/build_steps/compile.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2080,7 +2080,7 @@ pub fn stream_cargo(
20802080
tail_args: Vec<String>,
20812081
cb: &mut dyn FnMut(CargoMessage<'_>),
20822082
) -> bool {
2083-
let mut cargo = BootstrapCommand::from(cargo).command;
2083+
let mut cargo = cargo.into_cmd().command;
20842084
// Instruct Cargo to give us json messages on stdout, critically leaving
20852085
// stderr as piped so we can get those pretty colors.
20862086
let mut message_format = if builder.config.json_output {

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -738,7 +738,7 @@ fn doc_std(
738738
format!("library{} in {} format", crate_description(requested_crates), format.as_str());
739739
let _guard = builder.msg_doc(compiler, description, target);
740740

741-
builder.run(cargo);
741+
builder.run(cargo.into_cmd());
742742
builder.cp_link_r(&out_dir, out);
743743
}
744744

@@ -863,7 +863,7 @@ impl Step for Rustc {
863863
let proc_macro_out_dir = builder.stage_out(compiler, Mode::Rustc).join("doc");
864864
symlink_dir_force(&builder.config, &out, &proc_macro_out_dir);
865865

866-
builder.run(cargo);
866+
builder.run(cargo.into_cmd());
867867

868868
if !builder.config.dry_run() {
869869
// Sanity check on linked compiler crates
@@ -996,7 +996,7 @@ macro_rules! tool_doc {
996996
symlink_dir_force(&builder.config, &out, &proc_macro_out_dir);
997997

998998
let _guard = builder.msg_doc(compiler, stringify!($tool).to_lowercase(), target);
999-
builder.run(cargo);
999+
builder.run(cargo.into_cmd());
10001000

10011001
if !builder.config.dry_run() {
10021002
// Sanity check on linked doc directories

src/bootstrap/src/core/build_steps/format.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -160,16 +160,15 @@ pub fn format(build: &Builder<'_>, check: bool, all: bool, paths: &[PathBuf]) {
160160
override_builder.add(&format!("!{ignore}")).expect(&ignore);
161161
}
162162
}
163-
let git_available = build
164-
.run(helpers::git(None).print_on_failure().allow_failure().arg("--version"))
165-
.is_success();
163+
let git_available =
164+
build.run(helpers::git(None).capture().allow_failure().arg("--version")).is_success();
166165

167166
let mut adjective = None;
168167
if git_available {
169168
let in_working_tree = build
170169
.run(
171170
helpers::git(Some(&build.src))
172-
.print_on_failure()
171+
.capture()
173172
.allow_failure()
174173
.arg("rev-parse")
175174
.arg("--is-inside-work-tree"),

src/bootstrap/src/core/build_steps/run.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ impl Step for Miri {
158158
// after another --, so this must be at the end.
159159
miri.args(builder.config.args());
160160

161-
builder.run(miri);
161+
builder.run(miri.into_cmd());
162162
}
163163
}
164164

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

+24-28
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use crate::core::builder::{Builder, Compiler, Kind, RunConfig, ShouldRun, Step};
2626
use crate::core::config::flags::get_completion;
2727
use crate::core::config::flags::Subcommand;
2828
use crate::core::config::TargetSelection;
29-
use crate::utils::exec::{BootstrapCommand, OutputMode};
29+
use crate::utils::exec::BootstrapCommand;
3030
use crate::utils::helpers::{
3131
self, add_link_lib_path, add_rustdoc_cargo_linker_args, dylib_path, dylib_path_var,
3232
linker_args, linker_flags, output, t, target_supports_cranelift_backend, up_to_date,
@@ -150,16 +150,13 @@ You can skip linkcheck with --skip src/tools/linkchecker"
150150
builder.default_doc(&[]);
151151

152152
// Build the linkchecker before calling `msg`, since GHA doesn't support nested groups.
153-
let mut linkchecker = builder.tool_cmd(Tool::Linkchecker);
153+
let linkchecker = builder.tool_cmd(Tool::Linkchecker);
154154

155155
// Run the linkchecker.
156156
let _guard =
157157
builder.msg(Kind::Test, compiler.stage, "Linkcheck", bootstrap_host, bootstrap_host);
158158
let _time = helpers::timeit(builder);
159-
builder.run(
160-
BootstrapCommand::from(linkchecker.arg(builder.out.join(host.triple).join("doc")))
161-
.delay_failure(),
162-
);
159+
builder.run(linkchecker.delay_failure().arg(builder.out.join(host.triple).join("doc")));
163160
}
164161

165162
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
@@ -217,10 +214,7 @@ impl Step for HtmlCheck {
217214
));
218215

219216
builder.run(
220-
BootstrapCommand::from(
221-
builder.tool_cmd(Tool::HtmlChecker).arg(builder.doc_out(self.target)),
222-
)
223-
.delay_failure(),
217+
builder.tool_cmd(Tool::HtmlChecker).delay_failure().arg(builder.doc_out(self.target)),
224218
);
225219
}
226220
}
@@ -260,14 +254,13 @@ impl Step for Cargotest {
260254

261255
let _time = helpers::timeit(builder);
262256
let mut cmd = builder.tool_cmd(Tool::CargoTest);
263-
let cmd = cmd
264-
.arg(&cargo)
257+
cmd.arg(&cargo)
265258
.arg(&out_dir)
266259
.args(builder.config.test_args())
267260
.env("RUSTC", builder.rustc(compiler))
268261
.env("RUSTDOC", builder.rustdoc(compiler));
269-
add_rustdoc_cargo_linker_args(cmd, builder, compiler.host, LldThreads::No);
270-
builder.run(BootstrapCommand::from(cmd).delay_failure());
262+
add_rustdoc_cargo_linker_args(&mut cmd, builder, compiler.host, LldThreads::No);
263+
builder.run(cmd.delay_failure());
271264
}
272265
}
273266

@@ -763,12 +756,12 @@ impl Step for Clippy {
763756
cargo.env("HOST_LIBS", host_libs);
764757

765758
cargo.add_rustc_lib_path(builder);
766-
let mut cargo = prepare_cargo_test(cargo, &[], &[], "clippy", compiler, host, builder);
759+
let cargo = prepare_cargo_test(cargo, &[], &[], "clippy", compiler, host, builder);
767760

768761
let _guard = builder.msg_sysroot_tool(Kind::Test, compiler.stage, "clippy", host, host);
769762

770763
// Clippy reports errors if it blessed the outputs
771-
if builder.run(BootstrapCommand::from(&mut cargo).allow_failure()).is_success() {
764+
if builder.run(cargo.allow_failure()).is_success() {
772765
// The tests succeeded; nothing to do.
773766
return;
774767
}
@@ -821,7 +814,7 @@ impl Step for RustdocTheme {
821814
.env("RUSTC_BOOTSTRAP", "1");
822815
cmd.args(linker_args(builder, self.compiler.host, LldThreads::No));
823816

824-
builder.run(BootstrapCommand::from(&mut cmd).delay_failure());
817+
builder.run(cmd.delay_failure());
825818
}
826819
}
827820

@@ -1099,7 +1092,7 @@ HELP: to skip test's attempt to check tidiness, pass `--skip src/tools/tidy` to
10991092
}
11001093

11011094
builder.info("tidy check");
1102-
builder.run(BootstrapCommand::from(&mut cmd).delay_failure());
1095+
builder.run(cmd.delay_failure());
11031096

11041097
builder.info("x.py completions check");
11051098
let [bash, zsh, fish, powershell] = ["x.py.sh", "x.py.zsh", "x.py.fish", "x.py.ps1"]
@@ -1306,7 +1299,7 @@ impl Step for RunMakeSupport {
13061299
&[],
13071300
);
13081301

1309-
builder.run(cargo);
1302+
builder.run(cargo.into_cmd());
13101303

13111304
let lib_name = "librun_make_support.rlib";
13121305
let lib = builder.tools_dir(self.compiler).join(lib_name);
@@ -2187,7 +2180,7 @@ impl BookTest {
21872180
compiler.host,
21882181
);
21892182
let _time = helpers::timeit(builder);
2190-
let cmd = BootstrapCommand::from(&mut rustbook_cmd).delay_failure();
2183+
let cmd = rustbook_cmd.delay_failure();
21912184
let toolstate =
21922185
if builder.run(cmd).is_success() { ToolState::TestPass } else { ToolState::TestFail };
21932186
builder.save_toolstate(self.name, toolstate);
@@ -2318,7 +2311,7 @@ impl Step for ErrorIndex {
23182311
let guard =
23192312
builder.msg(Kind::Test, compiler.stage, "error-index", compiler.host, compiler.host);
23202313
let _time = helpers::timeit(builder);
2321-
builder.run(BootstrapCommand::from(&mut tool).output_mode(OutputMode::OnlyOnFailure));
2314+
builder.run(tool.capture());
23222315
drop(guard);
23232316
// The tests themselves need to link to std, so make sure it is
23242317
// available.
@@ -2349,7 +2342,7 @@ fn markdown_test(builder: &Builder<'_>, compiler: Compiler, markdown: &Path) ->
23492342

23502343
cmd = cmd.delay_failure();
23512344
if !builder.config.verbose_tests {
2352-
cmd = cmd.print_on_failure();
2345+
cmd = cmd.capture();
23532346
}
23542347
builder.run(cmd).is_success()
23552348
}
@@ -2375,10 +2368,13 @@ impl Step for RustcGuide {
23752368
builder.update_submodule(&relative_path);
23762369

23772370
let src = builder.src.join(relative_path);
2378-
let mut rustbook_cmd = builder.tool_cmd(Tool::Rustbook);
2379-
let cmd = BootstrapCommand::from(rustbook_cmd.arg("linkcheck").arg(&src)).delay_failure();
2380-
let toolstate =
2381-
if builder.run(cmd).is_success() { ToolState::TestPass } else { ToolState::TestFail };
2371+
let mut rustbook_cmd = builder.tool_cmd(Tool::Rustbook).delay_failure();
2372+
rustbook_cmd.arg("linkcheck").arg(&src);
2373+
let toolstate = if builder.run(rustbook_cmd).is_success() {
2374+
ToolState::TestPass
2375+
} else {
2376+
ToolState::TestFail
2377+
};
23822378
builder.save_toolstate("rustc-dev-guide", toolstate);
23832379
}
23842380
}
@@ -3347,7 +3343,7 @@ impl Step for CodegenCranelift {
33473343
.arg("testsuite.extended_sysroot");
33483344
cargo.args(builder.config.test_args());
33493345

3350-
builder.run(cargo);
3346+
builder.run(cargo.into_cmd());
33513347
}
33523348
}
33533349

@@ -3472,6 +3468,6 @@ impl Step for CodegenGCC {
34723468
.arg("--std-tests");
34733469
cargo.args(builder.config.test_args());
34743470

3475-
builder.run(cargo);
3471+
builder.run(cargo.into_cmd());
34763472
}
34773473
}

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,7 @@ impl Step for Rustdoc {
603603
&self.compiler.host,
604604
&target,
605605
);
606-
builder.run(cargo);
606+
builder.run(cargo.into_cmd());
607607

608608
// Cargo adds a number of paths to the dylib search path on windows, which results in
609609
// the wrong rustdoc being executed. To avoid the conflicting rustdocs, we name the "tool"
@@ -858,7 +858,7 @@ impl Step for LlvmBitcodeLinker {
858858
&self.extra_features,
859859
);
860860

861-
builder.run(cargo);
861+
builder.run(cargo.into_cmd());
862862

863863
let tool_out = builder
864864
.cargo_out(self.compiler, Mode::ToolRustc, self.target)

src/bootstrap/src/core/builder.rs

+4-6
Original file line numberDiff line numberDiff line change
@@ -2398,6 +2398,10 @@ impl Cargo {
23982398
cargo
23992399
}
24002400

2401+
pub fn into_cmd(self) -> BootstrapCommand {
2402+
self.into()
2403+
}
2404+
24012405
/// Same as `Cargo::new` except this one doesn't configure the linker with `Cargo::configure_linker`
24022406
pub fn new_for_mir_opt_tests(
24032407
builder: &Builder<'_>,
@@ -2622,9 +2626,3 @@ impl From<Cargo> for BootstrapCommand {
26222626
cargo.command
26232627
}
26242628
}
2625-
2626-
impl From<Cargo> for Command {
2627-
fn from(cargo: Cargo) -> Command {
2628-
BootstrapCommand::from(cargo).command
2629-
}
2630-
}

0 commit comments

Comments
 (0)