Skip to content

Commit b834834

Browse files
committed
refactor(distributable)!: replace install_if_not_installed() with ensure_installed()
1 parent 5647a9e commit b834834

File tree

3 files changed

+5
-21
lines changed

3 files changed

+5
-21
lines changed

src/cli/rustup_mode.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -717,7 +717,10 @@ async fn default_(
717717
}
718718
MaybeResolvableToolchainName::Some(ResolvableToolchainName::Official(toolchain)) => {
719719
let desc = toolchain.resolve(&cfg.get_default_host_triple()?)?;
720-
let status = DistributableToolchain::install_if_not_installed(cfg, &desc).await?;
720+
let status = cfg
721+
.ensure_installed(desc.clone(), vec![], vec![], None, true)
722+
.await?
723+
.0;
721724

722725
cfg.set_default(Some(&(&desc).into()))?;
723726

src/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -780,7 +780,7 @@ impl<'a> Cfg<'a> {
780780
// Returns a Toolchain matching the given ToolchainDesc, installing it and
781781
// the given components and targets if they aren't already installed.
782782
#[tracing::instrument(level = "trace", err(level = "trace"), skip_all)]
783-
async fn ensure_installed(
783+
pub(crate) async fn ensure_installed(
784784
&self,
785785
toolchain: ToolchainDesc,
786786
components: Vec<String>,

src/toolchain/distributable.rs

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ use crate::{
1717
DistOptions, PartialToolchainDesc, Profile, ToolchainDesc,
1818
},
1919
install::{InstallMethod, UpdateStatus},
20-
notifications::Notification,
2120
RustupError,
2221
};
2322

@@ -358,24 +357,6 @@ impl<'a> DistributableToolchain<'a> {
358357
Ok((status, Self::new(cfg, toolchain.clone())?))
359358
}
360359

361-
#[tracing::instrument(level = "trace", err(level = "trace"), skip_all)]
362-
pub async fn install_if_not_installed(
363-
cfg: &'a Cfg<'a>,
364-
desc: &ToolchainDesc,
365-
) -> anyhow::Result<UpdateStatus> {
366-
(cfg.notify_handler)(Notification::LookingForToolchain(desc));
367-
if Toolchain::exists(cfg, &desc.into())? {
368-
(cfg.notify_handler)(Notification::UsingExistingToolchain(desc));
369-
Ok(UpdateStatus::Unchanged)
370-
} else {
371-
Ok(
372-
Self::install(cfg, desc, &[], &[], cfg.get_profile()?, false)
373-
.await?
374-
.0,
375-
)
376-
}
377-
}
378-
379360
#[tracing::instrument(level = "trace", err(level = "trace"), skip_all)]
380361
pub(crate) async fn update(
381362
&mut self,

0 commit comments

Comments
 (0)