Skip to content

Commit 5af3afb

Browse files
committed
Inline async closure
1 parent 7eba73a commit 5af3afb

File tree

1 file changed

+21
-26
lines changed

1 file changed

+21
-26
lines changed

src/cli/self_update.rs

Lines changed: 21 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -532,32 +532,7 @@ pub(crate) async fn install(
532532
}
533533

534534
let no_modify_path = opts.no_modify_path;
535-
let install_res = move || async move {
536-
install_bins()?;
537-
538-
#[cfg(unix)]
539-
do_write_env_files()?;
540-
541-
if !opts.no_modify_path {
542-
#[cfg(windows)]
543-
do_add_to_programs()?;
544-
do_add_to_path()?;
545-
}
546-
547-
// If RUSTUP_HOME is not set, make sure it exists
548-
if process().var_os("RUSTUP_HOME").is_none() {
549-
let home = utils::home_dir()
550-
.map(|p| p.join(".rustup"))
551-
.ok_or_else(|| anyhow::anyhow!("could not find home dir to put .rustup in"))?;
552-
553-
fs::create_dir_all(home).context("unable to create ~/.rustup")?;
554-
}
555-
556-
maybe_install_rust(current_dir, verbose, quiet, opts).await?;
557-
Ok(utils::ExitCode(0))
558-
};
559-
560-
if let Err(e) = install_res().await {
535+
if let Err(e) = maybe_install_rust(current_dir, verbose, quiet, opts).await {
561536
report_error(&e);
562537

563538
// On windows, where installation happens in a console
@@ -848,6 +823,26 @@ async fn maybe_install_rust(
848823
quiet: bool,
849824
opts: InstallOpts<'_>,
850825
) -> Result<()> {
826+
install_bins()?;
827+
828+
#[cfg(unix)]
829+
do_write_env_files()?;
830+
831+
if !opts.no_modify_path {
832+
#[cfg(windows)]
833+
do_add_to_programs()?;
834+
do_add_to_path()?;
835+
}
836+
837+
// If RUSTUP_HOME is not set, make sure it exists
838+
if process().var_os("RUSTUP_HOME").is_none() {
839+
let home = utils::home_dir()
840+
.map(|p| p.join(".rustup"))
841+
.ok_or_else(|| anyhow::anyhow!("could not find home dir to put .rustup in"))?;
842+
843+
fs::create_dir_all(home).context("unable to create ~/.rustup")?;
844+
}
845+
851846
let mut cfg = common::set_globals(current_dir, verbose, quiet)?;
852847

853848
let (components, targets) = (opts.components, opts.targets);

0 commit comments

Comments
 (0)