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..20964cfba4 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, @@ -45,14 +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::Copy { .. } - | InstallMethod::Link { .. } + 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()); @@ -64,23 +59,23 @@ 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)), .. }) => UpdateStatus::Updated(v.clone()), - InstallMethod::Copy { .. } - | InstallMethod::Link { .. } - | InstallMethod::Dist { .. } => UpdateStatus::Installed, + InstallMethod::Link { .. } | InstallMethod::Dist { .. } => { + UpdateStatus::Installed + } } } }; // 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()), } } @@ -96,10 +91,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 +111,6 @@ impl InstallMethod<'_, '_> { fn cfg(&self) -> &Cfg<'_> { match self { - InstallMethod::Copy { cfg, .. } => cfg, InstallMethod::Link { cfg, .. } => cfg, InstallMethod::Dist(DistOptions { cfg, .. }) => cfg, } @@ -128,30 +118,15 @@ 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(), } } - fn dest_basename(&self) -> String { - self.local_name().to_string() - } - fn dest_path(&self) -> PathBuf { - match self { - InstallMethod::Copy { cfg, dest, .. } | 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()) } }