diff --git a/src/cli/rustup_mode.rs b/src/cli/rustup_mode.rs index 0a7b555976..34b3d87061 100644 --- a/src/cli/rustup_mode.rs +++ b/src/cli/rustup_mode.rs @@ -1667,7 +1667,7 @@ async fn component_remove( async fn toolchain_link( cfg: &Cfg<'_>, - dest: &CustomToolchainName, + toolchain: &CustomToolchainName, src: &Path, ) -> anyhow::Result { cfg.ensure_toolchains_dir()?; @@ -1683,7 +1683,7 @@ async fn toolchain_link( InstallMethod::Link { src: &cfg.current_dir.join(src), - dest, + toolchain, cfg, } .install(None) diff --git a/src/install.rs b/src/install.rs index 784b27d409..e360dad57c 100644 --- a/src/install.rs +++ b/src/install.rs @@ -8,7 +8,7 @@ use crate::{ config::Cfg, dist::{DistOptions, manifest::ManifestWithHash, prefix::InstallPrefix}, errors::RustupError, - toolchain::{CustomToolchainName, Toolchain}, + toolchain::{CustomToolchainName, LocalToolchainName, Toolchain}, utils, }; @@ -22,7 +22,7 @@ pub(crate) enum UpdateStatus { pub(crate) enum InstallMethod<'cfg, 'a> { Link { src: &'a Path, - dest: &'a CustomToolchainName, + toolchain: &'a CustomToolchainName, cfg: &'cfg Cfg<'cfg>, }, Dist(DistOptions<'cfg, 'a>), @@ -45,40 +45,39 @@ impl InstallMethod<'_, '_> { .num_threads(cfg.process.io_thread_count()?.into()) .build_global(); - let local_name = match &self { - Self::Link { dest, .. } => { - let name = (*dest).clone().into(); - debug!("linking toolchain {name}"); - name + let toolchain = match &self { + Self::Link { toolchain, .. } => { + let toolchain = LocalToolchainName::from((*toolchain).clone()); + debug!("linking toolchain `{toolchain}`"); + toolchain } Self::Dist(DistOptions { - toolchain: desc, + toolchain, old_date_version, .. }) => { - let name = (*desc).clone().into(); - if old_date_version.is_some() { - debug!("updating existing install for '{name}'"); - } else { - debug!("installing toolchain {name}"); + let toolchain = LocalToolchainName::from((*toolchain).clone()); + match old_date_version { + Some(_) => debug!("updating existing install for `{toolchain}`"), + None => debug!("installing toolchain `{toolchain}`"), } - name + toolchain } }; - let dest_path = &cfg.toolchain_path(&local_name); - debug!("toolchain directory: {}", dest_path.display()); - if dest_path.exists() && !matches!(self, Self::Dist { .. }) { - uninstall(dest_path)?; + let toolchain_path = &cfg.toolchain_path(&toolchain); + debug!("toolchain directory: {}", toolchain_path.display()); + if toolchain_path.exists() && !matches!(self, Self::Dist { .. }) { + uninstall(toolchain_path)?; } let status = match &self { Self::Link { src, .. } => { - utils::symlink_dir(src, dest_path)?; + utils::symlink_dir(src, toolchain_path)?; UpdateStatus::Installed } Self::Dist(opts) => match opts - .install_into(&InstallPrefix::from(dest_path.clone()), manifest) + .install_into(&InstallPrefix::from(toolchain_path.clone()), manifest) .await? { None => UpdateStatus::Unchanged, @@ -96,13 +95,13 @@ impl InstallMethod<'_, '_> { }; // Final check, to ensure we're installed - if !Toolchain::exists(cfg, &local_name)? { - return Err(RustupError::ToolchainNotInstallable(local_name.to_string()).into()); + if !Toolchain::exists(cfg, &toolchain)? { + return Err(RustupError::ToolchainNotInstallable(toolchain.to_string()).into()); } match &status { UpdateStatus::Unchanged => debug!("toolchain is already up to date"), - _ => debug!("toolchain {local_name} installed"), + _ => debug!("toolchain {toolchain} installed"), }; Ok(status)