From e7b4a079ffa9d2f57856810dfd1e02af77aa7f79 Mon Sep 17 00:00:00 2001 From: rami3l Date: Tue, 15 Sep 2026 15:13:45 +0200 Subject: [PATCH 1/3] refactor(toolchain/distributable): remove unused variant `InstallMethod::Copy{}` --- src/cli/rustup_mode.rs | 16 ++++++---------- src/install.rs | 27 ++++++--------------------- 2 files changed, 12 insertions(+), 31 deletions(-) diff --git a/src/cli/rustup_mode.rs b/src/cli/rustup_mode.rs index 06f14cd038..30f8de1750 100644 --- a/src/cli/rustup_mode.rs +++ b/src/cli/rustup_mode.rs @@ -1679,17 +1679,13 @@ async fn toolchain_link( pathbuf.push(format!("rustc{EXE_SUFFIX}")); utils::assert_is_file(&pathbuf)?; - if true { - InstallMethod::Link { - src: &cfg.current_dir.join(src), - dest, - cfg, - } - .install(None) - .await?; - } else { - InstallMethod::Copy { src, dest, cfg }.install(None).await?; + InstallMethod::Link { + src: &cfg.current_dir.join(src), + dest, + cfg, } + .install(None) + .await?; Ok(ExitCode::SUCCESS) } diff --git a/src/install.rs b/src/install.rs index 02b2d402ef..7638aef038 100644 --- a/src/install.rs +++ b/src/install.rs @@ -20,11 +20,6 @@ pub(crate) enum UpdateStatus { } pub(crate) enum InstallMethod<'cfg, 'a> { - Copy { - src: &'a Path, - dest: &'a CustomToolchainName, - cfg: &'cfg Cfg<'cfg>, - }, Link { src: &'a Path, dest: &'a CustomToolchainName, @@ -46,8 +41,7 @@ impl InstallMethod<'_, '_> { .num_threads(self.cfg().process.io_thread_count()?.into()) .build_global(); match &self { - InstallMethod::Copy { .. } - | InstallMethod::Link { .. } + InstallMethod::Link { .. } | InstallMethod::Dist(DistOptions { old_date_version: None, .. @@ -70,9 +64,9 @@ impl InstallMethod<'_, '_> { old_date_version: Some((_, v)), .. }) => UpdateStatus::Updated(v.clone()), - InstallMethod::Copy { .. } - | InstallMethod::Link { .. } - | InstallMethod::Dist { .. } => UpdateStatus::Installed, + InstallMethod::Link { .. } | InstallMethod::Dist { .. } => { + UpdateStatus::Installed + } } } }; @@ -96,10 +90,6 @@ impl InstallMethod<'_, '_> { } match self { - InstallMethod::Copy { src, .. } => { - utils::copy_dir(src, path)?; - Ok(true) - } InstallMethod::Link { src, .. } => { utils::symlink_dir(src, path)?; Ok(true) @@ -120,7 +110,6 @@ impl InstallMethod<'_, '_> { fn cfg(&self) -> &Cfg<'_> { match self { - InstallMethod::Copy { cfg, .. } => cfg, InstallMethod::Link { cfg, .. } => cfg, InstallMethod::Dist(DistOptions { cfg, .. }) => cfg, } @@ -128,9 +117,7 @@ impl InstallMethod<'_, '_> { fn local_name(&self) -> LocalToolchainName { match self { - InstallMethod::Copy { dest, .. } | InstallMethod::Link { dest, .. } => { - (*dest).clone().into() - } + InstallMethod::Link { dest, .. } => (*dest).clone().into(), InstallMethod::Dist(DistOptions { toolchain: desc, .. }) => (*desc).clone().into(), @@ -143,9 +130,7 @@ impl InstallMethod<'_, '_> { fn dest_path(&self) -> PathBuf { match self { - InstallMethod::Copy { cfg, dest, .. } | InstallMethod::Link { cfg, dest, .. } => { - cfg.toolchain_path(&(*dest).clone().into()) - } + InstallMethod::Link { cfg, dest, .. } => cfg.toolchain_path(&(*dest).clone().into()), InstallMethod::Dist(DistOptions { cfg, toolchain: desc, From e0e8ea250e234adf28550fca8c03bf93d836836d Mon Sep 17 00:00:00 2001 From: rami3l Date: Tue, 15 Sep 2026 15:15:39 +0200 Subject: [PATCH 2/3] refactor(toolchain/distributable): simplify `InstallMethod::dest_path()` --- src/install.rs | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/install.rs b/src/install.rs index 7638aef038..5ed82fef1f 100644 --- a/src/install.rs +++ b/src/install.rs @@ -129,14 +129,7 @@ impl InstallMethod<'_, '_> { } fn dest_path(&self) -> PathBuf { - match self { - InstallMethod::Link { cfg, dest, .. } => cfg.toolchain_path(&(*dest).clone().into()), - InstallMethod::Dist(DistOptions { - cfg, - toolchain: desc, - .. - }) => cfg.toolchain_path(&(*desc).clone().into()), - } + self.cfg().toolchain_path(&self.local_name()) } } From 4fdd25bcfec7059fc2f8998980ab02f15522587e Mon Sep 17 00:00:00 2001 From: rami3l Date: Tue, 15 Sep 2026 15:19:33 +0200 Subject: [PATCH 3/3] refactor(toolchain/distributable): inline `InstallMethod::dest_basename()` --- src/install.rs | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/install.rs b/src/install.rs index 5ed82fef1f..20964cfba4 100644 --- a/src/install.rs +++ b/src/install.rs @@ -40,13 +40,14 @@ impl InstallMethod<'_, '_> { let _ = rayon::ThreadPoolBuilder::new() .num_threads(self.cfg().process.io_thread_count()?.into()) .build_global(); + let local_name = self.local_name(); match &self { InstallMethod::Link { .. } | InstallMethod::Dist(DistOptions { old_date_version: None, .. - }) => debug!("installing toolchain {}", self.dest_basename()), - _ => debug!("updating existing install for '{}'", self.dest_basename()), + }) => debug!("installing toolchain {local_name}",), + _ => debug!("updating existing install for '{local_name}'"), } debug!("toolchain directory: {}", self.dest_path().display()); @@ -58,7 +59,7 @@ impl InstallMethod<'_, '_> { UpdateStatus::Unchanged } true => { - debug!("toolchain {} installed", self.dest_basename()); + debug!("toolchain {local_name} installed"); match &self { InstallMethod::Dist(DistOptions { old_date_version: Some((_, v)), @@ -72,9 +73,9 @@ impl InstallMethod<'_, '_> { }; // Final check, to ensure we're installed - match Toolchain::exists(self.cfg(), &self.local_name())? { + match Toolchain::exists(self.cfg(), &local_name)? { true => Ok(status), - false => Err(RustupError::ToolchainNotInstallable(self.dest_basename()).into()), + false => Err(RustupError::ToolchainNotInstallable(local_name.to_string()).into()), } } @@ -124,10 +125,6 @@ impl InstallMethod<'_, '_> { } } - fn dest_basename(&self) -> String { - self.local_name().to_string() - } - fn dest_path(&self) -> PathBuf { self.cfg().toolchain_path(&self.local_name()) }