Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/cli/rustup_mode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1051,7 +1051,7 @@ async fn update(
}
}
Err(RustupError::ToolchainNotInstalled { .. }) => {
DistributableToolchain::install(dist_opts).await?.0
DistributableToolchain::install(dist_opts).await?.status
}
Err(e) => Err(e)?,
};
Expand Down Expand Up @@ -1628,7 +1628,7 @@ async fn override_add(
ToolchainName::Custom(_) => Err(e)?,
ToolchainName::Official(desc) => {
let options = DistOptions::new(&[], &[], desc, cfg.get_profile()?, false, cfg)?;
let status = DistributableToolchain::install(options).await?.0;
let status = DistributableToolchain::install(options).await?.status;
writeln!(cfg.process.stdout().lock())?;
common::show_channel_update(
cfg,
Expand Down
2 changes: 1 addition & 1 deletion src/cli/self_update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1036,7 +1036,7 @@ async fn maybe_install_rust(opts: InstallOpts<'_>, cfg: &mut Cfg<'_>) -> Result<
.install(None)
.await?
} else {
DistributableToolchain::install(options).await?.0
DistributableToolchain::install(options).await?.status
};

check_proxy_sanity(cfg.process, components, desc)?;
Expand Down
10 changes: 5 additions & 5 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -862,9 +862,10 @@ impl<'a> Cfg<'a> {
self,
)?;

let (status, toolchain) = match DistributableToolchain::new(self, toolchain.clone()) {
Ok(match DistributableToolchain::new(self, toolchain.clone()) {
Err(RustupError::ToolchainNotInstalled { .. }) => {
DistributableToolchain::install(options).await?
let tc = DistributableToolchain::install(options).await?;
EnsureInstalled::new(tc.inner.into(), tc.status)
}
Ok(distributable) => {
if verbose {
Expand All @@ -878,11 +879,10 @@ impl<'a> Cfg<'a> {
} else {
UpdateStatus::Unchanged
};
(status, distributable)
EnsureInstalled::new(distributable.into(), status)
}
Err(e) => return Err(e.into()),
};
Ok(EnsureInstalled::new(toolchain.into(), status))
})
}

/// Get the configured default toolchain.
Expand Down
4 changes: 2 additions & 2 deletions src/toolchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ impl<'a> Toolchain<'a> {
..
}) if install_if_missing => {
let options = DistOptions::new(&[], &[], &desc, cfg.get_profile()?, true, cfg)?;
let tc = DistributableToolchain::install(options).await?.1.toolchain;
Ok(EnsureInstalled::new(tc, UpdateStatus::Installed))
let tc = DistributableToolchain::install(options).await?;
Ok(EnsureInstalled::new(tc.inner.into(), tc.status))
}
Err(e) => Err(e.into()),
}
Expand Down
11 changes: 7 additions & 4 deletions src/toolchain/distributable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use platforms::Platform;

use crate::{
RustupError, component_for_bin,
config::{ActiveSource, Cfg},
config::{ActiveSource, Cfg, EnsureInstalled},
dist::{
DistOptions, PartialToolchainDesc, ToolchainDesc,
config::Config,
Expand All @@ -18,7 +18,7 @@ use crate::{
manifestation::{Changes, Manifestation},
prefix::InstallPrefix,
},
install::{InstallMethod, UpdateStatus},
install::InstallMethod,
};

use crate::errors::UnknownComponentInfo;
Expand All @@ -39,10 +39,13 @@ impl<'a> DistributableToolchain<'a> {
#[tracing::instrument(level = "trace", err(level = "trace"), skip_all)]
pub(crate) async fn install(
options: DistOptions<'a, '_>,
) -> anyhow::Result<(UpdateStatus, Self)> {
) -> anyhow::Result<EnsureInstalled<Self>> {
let (cfg, toolchain) = (options.cfg, options.toolchain);
let status = InstallMethod::Dist(options).install(None).await?;
Ok((status, Self::new(cfg, toolchain.clone())?))
Ok(EnsureInstalled::new(
Self::new(cfg, toolchain.clone())?,
status,
))
}

pub(crate) async fn from_partial(
Expand Down
Loading