From 8e02419f6e975851db51515b4c9df56cee3d3be2 Mon Sep 17 00:00:00 2001 From: rami3l Date: Wed, 16 Sep 2026 14:32:34 +0200 Subject: [PATCH 1/3] refactor(install): rename `dest` to `toolchain` in `InstallMethod` --- src/cli/rustup_mode.rs | 4 ++-- src/install.rs | 22 +++++++++++----------- 2 files changed, 13 insertions(+), 13 deletions(-) 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..4b9e3a90a0 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>), @@ -46,23 +46,23 @@ impl InstallMethod<'_, '_> { .build_global(); let local_name = match &self { - Self::Link { dest, .. } => { - let name = (*dest).clone().into(); - debug!("linking toolchain {name}"); - name + 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(); + let toolchain = LocalToolchainName::from((*toolchain).clone()); if old_date_version.is_some() { - debug!("updating existing install for '{name}'"); + debug!("updating existing install for `{toolchain}`"); } else { - debug!("installing toolchain {name}"); + debug!("installing toolchain `{toolchain}`"); } - name + toolchain } }; From ff50cef8b252eb748eef04743b9ea940351877ad Mon Sep 17 00:00:00 2001 From: rami3l Date: Wed, 16 Sep 2026 14:37:00 +0200 Subject: [PATCH 2/3] refactor(install): shorten pattern matching --- src/install.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/install.rs b/src/install.rs index 4b9e3a90a0..58132fdddd 100644 --- a/src/install.rs +++ b/src/install.rs @@ -57,10 +57,9 @@ impl InstallMethod<'_, '_> { .. }) => { let toolchain = LocalToolchainName::from((*toolchain).clone()); - if old_date_version.is_some() { - debug!("updating existing install for `{toolchain}`"); - } else { - debug!("installing toolchain `{toolchain}`"); + match old_date_version { + Some(_) => debug!("updating existing install for `{toolchain}`"), + None => debug!("installing toolchain `{toolchain}`"), } toolchain } From 1787daa14373eee95bccb898a98e5288fa90d3be Mon Sep 17 00:00:00 2001 From: rami3l Date: Wed, 16 Sep 2026 14:37:00 +0200 Subject: [PATCH 3/3] refactor(install): use more descriptive variable names --- src/install.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/install.rs b/src/install.rs index 58132fdddd..e360dad57c 100644 --- a/src/install.rs +++ b/src/install.rs @@ -45,7 +45,7 @@ impl InstallMethod<'_, '_> { .num_threads(cfg.process.io_thread_count()?.into()) .build_global(); - let local_name = match &self { + let toolchain = match &self { Self::Link { toolchain, .. } => { let toolchain = LocalToolchainName::from((*toolchain).clone()); debug!("linking toolchain `{toolchain}`"); @@ -65,19 +65,19 @@ impl InstallMethod<'_, '_> { } }; - 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, @@ -95,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)