diff --git a/src/cli/common.rs b/src/cli/common.rs index a7eb5ff1e0..b7c086b6d0 100644 --- a/src/cli/common.rs +++ b/src/cli/common.rs @@ -233,23 +233,24 @@ pub(crate) async fn update_all_channels( check: bool, ) -> anyhow::Result { let profile = cfg.get_profile()?; - let channels = cfg.list_channels()?; + let channels = cfg.list_tracking_channels()?; // Run a pre-check to determine which channels have updates available. - let channels_with_manifests = join_all(channels.into_iter().map(|(desc, d)| async move { + let channels_with_manifests = join_all(channels.into_iter().map(|d| async move { // Prefetch errors are intentionally discarded; a failed prefetch falls // back to the normal update path, where errors are properly propagated. let manifest = d.fetch_dist_manifest().await.unwrap_or(None); - (desc, d, manifest) + (d, manifest) })) .await; let mut toolchains = Vec::with_capacity(channels_with_manifests.len()); let mut has_update_error = false; let mut has_update = false; - for (desc, distributable, manifest) in channels_with_manifests { + for (distributable, manifest) in channels_with_manifests { + let desc = distributable.desc(); let result = if force_update || manifest.is_some() { - let options = DistOptions::new(&[], &[], &desc, profile, force_update, cfg)? + let options = DistOptions::new(&[], &[], desc, profile, force_update, cfg)? .for_update(&distributable, false); InstallMethod::Dist(options).install(manifest).await } else { @@ -265,7 +266,7 @@ pub(crate) async fn update_all_channels( _ => (), } - toolchains.push((desc, result)); + toolchains.push((desc.clone(), result)); } let exit_code = if has_update_error { diff --git a/src/cli/rustup_mode.rs b/src/cli/rustup_mode.rs index a4d8e49d50..080e888631 100644 --- a/src/cli/rustup_mode.rs +++ b/src/cli/rustup_mode.rs @@ -951,7 +951,7 @@ async fn check_updates(cfg: &Cfg<'_>, opts: CheckOpts) -> anyhow::Result, opts: CheckOpts) -> anyhow::Result Cfg<'a> { Ok(toolchains) } - pub(crate) fn list_channels( - &self, - ) -> anyhow::Result)>> { + pub(crate) fn list_tracking_channels(&self) -> anyhow::Result>> { let mut channels = self .list_toolchains(true)? .into_iter() .filter_map(|t| match t { ToolchainName::Channel(n) if n.is_tracking() => { - Some(ChannelToolchain::new(self, n.clone()).map(|t| (n, t))) + Some(ChannelToolchain::new(self, n)) } _ => None, }) @@ -1049,7 +1047,7 @@ impl<'a> Cfg<'a> { // HACK: `.sort_by_key()` is impossible here without cloning. // See: - channels.sort_by(|(n, _), (m, _)| n.cmp(m)); + channels.sort_by(|n, m| n.desc().cmp(m.desc())); Ok(channels) }