Skip to content

Commit 883e861

Browse files
rami3ldjc
authored andcommitted
feat(config): make create_command_for_toolchain() async
1 parent 408ac23 commit 883e861

File tree

3 files changed

+15
-12
lines changed

3 files changed

+15
-12
lines changed

src/cli/proxy_mode.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ async fn direct_proxy(
5555
cfg.create_command_for_dir(&utils::current_dir()?, arg0)
5656
.await?
5757
}
58-
Some(tc) => cfg.create_command_for_toolchain(&tc, false, arg0)?,
58+
Some(tc) => cfg.create_command_for_toolchain(&tc, false, arg0).await?,
5959
};
6060
run_command_for_dir(cmd, arg0, args)
6161
}

src/cli/rustup_mode.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -675,7 +675,9 @@ pub async fn main() -> Result<utils::ExitCode> {
675675
toolchain,
676676
command,
677677
install,
678-
} => run(cfg, toolchain, command, install).map(ExitCode::from),
678+
} => run(cfg, toolchain, command, install)
679+
.await
680+
.map(ExitCode::from),
679681
RustupSubcmd::Which { command, toolchain } => which(cfg, &command, toolchain).await,
680682
RustupSubcmd::Doc {
681683
path,
@@ -893,14 +895,16 @@ async fn update(cfg: &mut Cfg, opts: UpdateOpts) -> Result<utils::ExitCode> {
893895
Ok(utils::ExitCode(0))
894896
}
895897

896-
fn run(
898+
async fn run(
897899
cfg: &Cfg,
898900
toolchain: ResolvableLocalToolchainName,
899901
command: Vec<String>,
900902
install: bool,
901903
) -> Result<ExitStatus> {
902904
let toolchain = toolchain.resolve(&cfg.get_default_host_triple()?)?;
903-
let cmd = cfg.create_command_for_toolchain(&toolchain, install, &command[0])?;
905+
let cmd = cfg
906+
.create_command_for_toolchain(&toolchain, install, &command[0])
907+
.await?;
904908
command::run_command_for_dir(cmd, &command[0], &command[1..])
905909
}
906910

src/config.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -808,11 +808,9 @@ impl Cfg {
808808
}
809809
Ok(mut distributable) => {
810810
if !distributable.components_exist(&components, &targets)? {
811-
utils::run_future(distributable.update(
812-
&components,
813-
&targets,
814-
profile.unwrap_or(Profile::Default),
815-
))?;
811+
distributable
812+
.update(&components, &targets, profile.unwrap_or(Profile::Default))
813+
.await?;
816814
}
817815
distributable
818816
}
@@ -942,7 +940,7 @@ impl Cfg {
942940
self.create_command_for_toolchain_(toolchain, binary)
943941
}
944942

945-
pub(crate) fn create_command_for_toolchain(
943+
pub(crate) async fn create_command_for_toolchain(
946944
&self,
947945
toolchain_name: &LocalToolchainName,
948946
install_if_missing: bool,
@@ -953,14 +951,15 @@ impl Cfg {
953951
match DistributableToolchain::new(self, desc.clone()) {
954952
Err(RustupError::ToolchainNotInstalled(_)) => {
955953
if install_if_missing {
956-
utils::run_future(DistributableToolchain::install(
954+
DistributableToolchain::install(
957955
self,
958956
desc,
959957
&[],
960958
&[],
961959
self.get_profile()?,
962960
true,
963-
))?;
961+
)
962+
.await?;
964963
}
965964
}
966965
o => {

0 commit comments

Comments
 (0)