Skip to content

Commit e4240bb

Browse files
committed
Remove temporary BootstrapCommand trait impls
1 parent e824b16 commit e4240bb

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
@@ -2077,7 +2077,7 @@ pub fn stream_cargo(
20772077
tail_args: Vec<String>,
20782078
cb: &mut dyn FnMut(CargoMessage<'_>),
20792079
) -> bool {
2080-
let mut cargo = BootstrapCommand::from(cargo).command;
2080+
let mut cargo = cargo.into_cmd().command;
20812081
// Instruct Cargo to give us json messages on stdout, critically leaving
20822082
// stderr as piped so we can get those pretty colors.
20832083
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);
@@ -2185,7 +2178,7 @@ impl BookTest {
21852178
compiler.host,
21862179
);
21872180
let _time = helpers::timeit(builder);
2188-
let cmd = BootstrapCommand::from(&mut rustbook_cmd).delay_failure();
2181+
let cmd = rustbook_cmd.delay_failure();
21892182
let toolstate =
21902183
if builder.run(cmd).is_success() { ToolState::TestPass } else { ToolState::TestFail };
21912184
builder.save_toolstate(self.name, toolstate);
@@ -2316,7 +2309,7 @@ impl Step for ErrorIndex {
23162309
let guard =
23172310
builder.msg(Kind::Test, compiler.stage, "error-index", compiler.host, compiler.host);
23182311
let _time = helpers::timeit(builder);
2319-
builder.run(BootstrapCommand::from(&mut tool).output_mode(OutputMode::OnlyOnFailure));
2312+
builder.run(tool.capture());
23202313
drop(guard);
23212314
// The tests themselves need to link to std, so make sure it is
23222315
// available.
@@ -2347,7 +2340,7 @@ fn markdown_test(builder: &Builder<'_>, compiler: Compiler, markdown: &Path) ->
23472340

23482341
cmd = cmd.delay_failure();
23492342
if !builder.config.verbose_tests {
2350-
cmd = cmd.print_on_failure();
2343+
cmd = cmd.capture();
23512344
}
23522345
builder.run(cmd).is_success()
23532346
}
@@ -2373,10 +2366,13 @@ impl Step for RustcGuide {
23732366
builder.update_submodule(&relative_path);
23742367

23752368
let src = builder.src.join(relative_path);
2376-
let mut rustbook_cmd = builder.tool_cmd(Tool::Rustbook);
2377-
let cmd = BootstrapCommand::from(rustbook_cmd.arg("linkcheck").arg(&src)).delay_failure();
2378-
let toolstate =
2379-
if builder.run(cmd).is_success() { ToolState::TestPass } else { ToolState::TestFail };
2369+
let mut rustbook_cmd = builder.tool_cmd(Tool::Rustbook).delay_failure();
2370+
rustbook_cmd.arg("linkcheck").arg(&src);
2371+
let toolstate = if builder.run(rustbook_cmd).is_success() {
2372+
ToolState::TestPass
2373+
} else {
2374+
ToolState::TestFail
2375+
};
23802376
builder.save_toolstate("rustc-dev-guide", toolstate);
23812377
}
23822378
}
@@ -3345,7 +3341,7 @@ impl Step for CodegenCranelift {
33453341
.arg("testsuite.extended_sysroot");
33463342
cargo.args(builder.config.test_args());
33473343

3348-
builder.run(cargo);
3344+
builder.run(cargo.into_cmd());
33493345
}
33503346
}
33513347

@@ -3470,6 +3466,6 @@ impl Step for CodegenGCC {
34703466
.arg("--std-tests");
34713467
cargo.args(builder.config.test_args());
34723468

3473-
builder.run(cargo);
3469+
builder.run(cargo.into_cmd());
34743470
}
34753471
}

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,7 @@ impl Step for Rustdoc {
602602
&self.compiler.host,
603603
&target,
604604
);
605-
builder.run(cargo);
605+
builder.run(cargo.into_cmd());
606606

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

860-
builder.run(cargo);
860+
builder.run(cargo.into_cmd());
861861

862862
let tool_out = builder
863863
.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)