Skip to content

Commit e97627e

Browse files
rami3ldjc
authored andcommitted
refactor(self_update): make maybe_install_rust() async
1 parent 6494655 commit e97627e

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

src/cli/self_update.rs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ pub(crate) async fn install(
458458
}
459459
}
460460

461-
let install_res: Result<utils::ExitCode> = (|| {
461+
let install_res = || async {
462462
install_bins()?;
463463

464464
#[cfg(unix)]
@@ -478,12 +478,13 @@ pub(crate) async fn install(
478478
opts.targets,
479479
verbose,
480480
quiet,
481-
)?;
481+
)
482+
.await?;
482483

483484
Ok(utils::ExitCode(0))
484-
})();
485+
};
485486

486-
if let Err(e) = install_res {
487+
if let Err(e) = install_res().await {
487488
report_error(&e);
488489

489490
// On windows, where installation happens in a console
@@ -839,7 +840,7 @@ pub(crate) fn install_proxies() -> Result<()> {
839840
Ok(())
840841
}
841842

842-
fn maybe_install_rust(
843+
async fn maybe_install_rust(
843844
toolchain: Option<MaybeOfficialToolchainName>,
844845
profile_str: &str,
845846
default_host_triple: Option<&str>,
@@ -869,16 +870,19 @@ fn maybe_install_rust(
869870
// - delete the partial install and start over
870871
// For now, we error.
871872
let mut toolchain = DistributableToolchain::new(&cfg, desc.clone())?;
872-
utils::run_future(toolchain.update(components, targets, cfg.get_profile()?))?
873+
toolchain
874+
.update(components, targets, cfg.get_profile()?)
875+
.await?
873876
} else {
874-
utils::run_future(DistributableToolchain::install(
877+
DistributableToolchain::install(
875878
&cfg,
876879
desc,
877880
components,
878881
targets,
879882
cfg.get_profile()?,
880883
true,
881-
))?
884+
)
885+
.await?
882886
.0
883887
};
884888

0 commit comments

Comments
 (0)