Skip to content

Commit f7d9543

Browse files
committed
Migrate cargo_clippy_cmd and cargo_miri_cmd to BootstrapCommand
1 parent 86b2191 commit f7d9543

File tree

3 files changed

+15
-17
lines changed

3 files changed

+15
-17
lines changed

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

Lines changed: 1 addition & 1 deletion
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 = Command::from(cargo);
2080+
let mut cargo = BootstrapCommand::from(cargo).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/run.rs

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

161-
let mut miri = Command::from(miri);
162-
builder.run(&mut miri);
161+
builder.run(miri);
163162
}
164163
}
165164

src/bootstrap/src/core/builder.rs

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1251,11 +1251,11 @@ impl<'a> Builder<'a> {
12511251
self.ensure(tool::Rustdoc { compiler })
12521252
}
12531253

1254-
pub fn cargo_clippy_cmd(&self, run_compiler: Compiler) -> Command {
1254+
pub fn cargo_clippy_cmd(&self, run_compiler: Compiler) -> BootstrapCommand {
12551255
if run_compiler.stage == 0 {
12561256
// `ensure(Clippy { stage: 0 })` *builds* clippy with stage0, it doesn't use the beta clippy.
12571257
let cargo_clippy = self.build.config.download_clippy();
1258-
let mut cmd = Command::new(cargo_clippy);
1258+
let mut cmd = BootstrapCommand::new(cargo_clippy);
12591259
cmd.env("CARGO", &self.initial_cargo);
12601260
return cmd;
12611261
}
@@ -1274,13 +1274,13 @@ impl<'a> Builder<'a> {
12741274
let mut dylib_path = helpers::dylib_path();
12751275
dylib_path.insert(0, self.sysroot(run_compiler).join("lib"));
12761276

1277-
let mut cmd = Command::new(cargo_clippy);
1277+
let mut cmd = BootstrapCommand::new(cargo_clippy);
12781278
cmd.env(helpers::dylib_path_var(), env::join_paths(&dylib_path).unwrap());
12791279
cmd.env("CARGO", &self.initial_cargo);
12801280
cmd
12811281
}
12821282

1283-
pub fn cargo_miri_cmd(&self, run_compiler: Compiler) -> Command {
1283+
pub fn cargo_miri_cmd(&self, run_compiler: Compiler) -> BootstrapCommand {
12841284
assert!(run_compiler.stage > 0, "miri can not be invoked at stage 0");
12851285
let build_compiler = self.compiler(run_compiler.stage - 1, self.build.build);
12861286

@@ -1296,7 +1296,7 @@ impl<'a> Builder<'a> {
12961296
extra_features: Vec::new(),
12971297
});
12981298
// Invoke cargo-miri, make sure it can find miri and cargo.
1299-
let mut cmd = Command::new(cargo_miri);
1299+
let mut cmd = BootstrapCommand::new(cargo_miri);
13001300
cmd.env("MIRI", &miri);
13011301
cmd.env("CARGO", &self.initial_cargo);
13021302
// Need to add the `run_compiler` libs. Those are the libs produces *by* `build_compiler`,
@@ -1353,7 +1353,7 @@ impl<'a> Builder<'a> {
13531353
mode: Mode,
13541354
target: TargetSelection,
13551355
cmd: &str, // FIXME make this properly typed
1356-
) -> Command {
1356+
) -> BootstrapCommand {
13571357
let mut cargo;
13581358
if cmd == "clippy" {
13591359
cargo = self.cargo_clippy_cmd(compiler);
@@ -1366,7 +1366,7 @@ impl<'a> Builder<'a> {
13661366
cargo = self.cargo_miri_cmd(compiler);
13671367
cargo.arg("miri").arg(subcmd);
13681368
} else {
1369-
cargo = Command::new(&self.initial_cargo);
1369+
cargo = BootstrapCommand::new(&self.initial_cargo);
13701370
cargo.arg(cmd);
13711371
}
13721372

@@ -2374,7 +2374,7 @@ impl HostFlags {
23742374

23752375
#[derive(Debug)]
23762376
pub struct Cargo {
2377-
command: Command,
2377+
command: BootstrapCommand,
23782378
compiler: Compiler,
23792379
target: TargetSelection,
23802380
rustflags: Rustflags,
@@ -2599,8 +2599,8 @@ impl Cargo {
25992599
}
26002600
}
26012601

2602-
impl From<Cargo> for Command {
2603-
fn from(mut cargo: Cargo) -> Command {
2602+
impl From<Cargo> for BootstrapCommand {
2603+
fn from(mut cargo: Cargo) -> BootstrapCommand {
26042604
let rustflags = &cargo.rustflags.0;
26052605
if !rustflags.is_empty() {
26062606
cargo.command.env("RUSTFLAGS", rustflags);
@@ -2619,13 +2619,12 @@ impl From<Cargo> for Command {
26192619
if !cargo.allow_features.is_empty() {
26202620
cargo.command.env("RUSTC_ALLOW_FEATURES", cargo.allow_features);
26212621
}
2622-
26232622
cargo.command
26242623
}
26252624
}
26262625

2627-
impl From<Cargo> for BootstrapCommand {
2628-
fn from(cargo: Cargo) -> BootstrapCommand {
2629-
Command::from(cargo).into()
2626+
impl From<Cargo> for Command {
2627+
fn from(cargo: Cargo) -> Command {
2628+
BootstrapCommand::from(cargo).command
26302629
}
26312630
}

0 commit comments

Comments
 (0)