From dc5ff3da74549b8a247591fd9b6cde5ce9106843 Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Thu, 2 Oct 2025 09:42:08 +0200 Subject: [PATCH 01/19] notifications: use human-friendly log format for path canonicalization --- src/utils/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/mod.rs b/src/utils/mod.rs index 6c04454565..445ee55c2d 100644 --- a/src/utils/mod.rs +++ b/src/utils/mod.rs @@ -129,7 +129,7 @@ pub(crate) fn filter_file bool>( pub(crate) fn canonicalize_path(path: &Path) -> PathBuf { fs::canonicalize(path).unwrap_or_else(|_| { - warn!(path = %path.display(), "could not canonicalize path"); + warn!("could not canonicalize path {}", path.display()); PathBuf::from(path) }) } From 205ae41d38c88ffad8749fcfc827486eabcf97f2 Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Thu, 2 Oct 2025 09:44:20 +0200 Subject: [PATCH 02/19] notifications: use human-friendly log format for retrying renames --- src/utils/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/mod.rs b/src/utils/mod.rs index 445ee55c2d..0eef74dc39 100644 --- a/src/utils/mod.rs +++ b/src/utils/mod.rs @@ -407,7 +407,7 @@ pub fn rename( // Permission denied, but as we work in users home dirs and // running programs like virus scanner are known to cause this // the heuristic is quite good. - info!(source = %src.display(), destination = %dest.display(), "renaming file in use, retrying"); + info!("retrying renaming {} to {}", src.display(), dest.display()); OperationResult::Retry(e) } #[cfg(target_os = "linux")] From 488c78eef8916018cd0b7bdeddb65d00d8e2cf2b Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Thu, 2 Oct 2025 09:49:43 +0200 Subject: [PATCH 03/19] notifications: use human-friendly log format for directory deletions --- src/dist/temp.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/dist/temp.rs b/src/dist/temp.rs index 66ab6995fc..1b95da0bcf 100644 --- a/src/dist/temp.rs +++ b/src/dist/temp.rs @@ -36,7 +36,10 @@ impl Drop for Dir { match remove_dir_all::remove_dir_all(&self.path) { Ok(()) => debug!(path = %self.path.display(), "deleted temp directory"), Err(e) => { - warn!(path = %self.path.display(), error = %e, "could not delete temp directory") + warn!( + "could not delete temp directory {} ({e})", + self.path.display() + ) } } } From 44f37aab7b1f69d7a3cb975edd523aa1305860d3 Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Thu, 2 Oct 2025 09:52:51 +0200 Subject: [PATCH 04/19] notifications: use human-friendly log format for temp file deletions --- src/dist/temp.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dist/temp.rs b/src/dist/temp.rs index 1b95da0bcf..0eacbb44f6 100644 --- a/src/dist/temp.rs +++ b/src/dist/temp.rs @@ -65,7 +65,7 @@ impl Drop for File { match fs::remove_file(&self.path) { Ok(()) => debug!(path = %self.path.display(), "deleted temp file"), Err(e) => { - warn!(path = %self.path.display(), error = %e, "could not delete temp file") + warn!("could not delete temp file {} ({e})", self.path.display()) } } } From d91511acfa30fe63621425c9f6f4ce61126481bf Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Thu, 2 Oct 2025 09:56:33 +0200 Subject: [PATCH 05/19] notifications: log directly when setting overrides --- src/config.rs | 2 +- src/notifications.rs | 10 +--------- src/settings.rs | 14 ++++++-------- 3 files changed, 8 insertions(+), 18 deletions(-) diff --git a/src/config.rs b/src/config.rs index b4c574fdc7..e35260c16d 100644 --- a/src/config.rs +++ b/src/config.rs @@ -919,7 +919,7 @@ impl<'a> Cfg<'a> { /// Create an override for a toolchain pub(crate) fn make_override(&self, path: &Path, toolchain: &ToolchainName) -> Result<()> { self.settings_file.with_mut(|s| { - s.add_override(path, toolchain.to_string(), self.notify_handler.as_ref()); + s.add_override(path, toolchain.to_string()); Ok(()) }) } diff --git a/src/notifications.rs b/src/notifications.rs index 903c19a142..268d012655 100644 --- a/src/notifications.rs +++ b/src/notifications.rs @@ -26,7 +26,6 @@ pub(crate) enum Notification<'a> { /// member, but the notification callback is already narrowed to /// utils::notifications by the time tar unpacking is called. SetDefaultBufferSize(usize), - SetOverrideToolchain(&'a Path, &'a str), SetProfile(&'a str), SetSelfUpdate(&'a str), LookingForToolchain(&'a ToolchainDesc), @@ -68,8 +67,7 @@ impl Notification<'_> { | ReadMetadataVersion(_) | InstalledToolchain(_) | UpdateHashMatches => NotificationLevel::Debug, - SetOverrideToolchain(_, _) - | SetProfile(_) + SetProfile(_) | SetSelfUpdate(_) | UsingExistingToolchain(_) | UninstallingToolchain(_) @@ -104,12 +102,6 @@ impl Display for Notification<'_> { DownloadDataReceived(data, _) => write!(f, "received some data of size {}", data.len()), DownloadFinished(_) => write!(f, "download finished"), DownloadFailed(_) => write!(f, "download failed"), - SetOverrideToolchain(path, name) => write!( - f, - "override toolchain for '{}' set to '{}'", - path.display(), - name - ), SetProfile(name) => write!(f, "profile set to '{name}'"), SetSelfUpdate(mode) => write!(f, "auto-self-update mode set to '{mode}'"), LookingForToolchain(name) => write!(f, "looking for installed toolchain '{name}'"), diff --git a/src/settings.rs b/src/settings.rs index efbc39da0b..4e503aa4c8 100644 --- a/src/settings.rs +++ b/src/settings.rs @@ -6,11 +6,11 @@ use std::str::FromStr; use anyhow::{Context, Result}; use serde::{Deserialize, Serialize}; +use tracing::info; use crate::cli::self_update::SelfUpdateMode; use crate::dist::{AutoInstallMode, Profile}; use crate::errors::*; -use crate::notifications::*; use crate::utils; #[derive(Clone, Debug, Eq, PartialEq)] @@ -111,14 +111,12 @@ impl Settings { self.overrides.remove(&key).is_some() } - pub(crate) fn add_override( - &mut self, - path: &Path, - toolchain: String, - notify_handler: &dyn Fn(Notification<'_>), - ) { + pub(crate) fn add_override(&mut self, path: &Path, toolchain: String) { let key = Self::path_to_key(path); - notify_handler(Notification::SetOverrideToolchain(path, &toolchain)); + info!( + "override toolchain for {} set to {toolchain}", + path.display(), + ); self.overrides.insert(key, toolchain); } From c132bb106f550e87fb1e9595184f5f5048d7b4f5 Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Thu, 2 Oct 2025 09:58:15 +0200 Subject: [PATCH 06/19] notifications: log directly when setting profile --- src/cli/self_update.rs | 2 +- src/config.rs | 2 +- src/notifications.rs | 5 +---- tests/suite/cli_misc.rs | 2 +- 4 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/cli/self_update.rs b/src/cli/self_update.rs index dfcd374bd2..ea421f7b3f 100644 --- a/src/cli/self_update.rs +++ b/src/cli/self_update.rs @@ -1427,7 +1427,7 @@ mod tests { ); assert_eq!( for_host!( - r"info: profile set to 'default' + r"info: profile set to default info: default host triple is {0} " ), diff --git a/src/config.rs b/src/config.rs index e35260c16d..4adeb909fe 100644 --- a/src/config.rs +++ b/src/config.rs @@ -359,7 +359,7 @@ impl<'a> Cfg<'a> { s.profile = Some(profile); Ok(()) })?; - (self.notify_handler)(Notification::SetProfile(profile.as_str())); + info!("profile set to {}", profile.as_str()); Ok(()) } diff --git a/src/notifications.rs b/src/notifications.rs index 268d012655..044ac87649 100644 --- a/src/notifications.rs +++ b/src/notifications.rs @@ -26,7 +26,6 @@ pub(crate) enum Notification<'a> { /// member, but the notification callback is already narrowed to /// utils::notifications by the time tar unpacking is called. SetDefaultBufferSize(usize), - SetProfile(&'a str), SetSelfUpdate(&'a str), LookingForToolchain(&'a ToolchainDesc), ToolchainDirectory(&'a Path), @@ -67,8 +66,7 @@ impl Notification<'_> { | ReadMetadataVersion(_) | InstalledToolchain(_) | UpdateHashMatches => NotificationLevel::Debug, - SetProfile(_) - | SetSelfUpdate(_) + SetSelfUpdate(_) | UsingExistingToolchain(_) | UninstallingToolchain(_) | UninstalledToolchain(_) @@ -102,7 +100,6 @@ impl Display for Notification<'_> { DownloadDataReceived(data, _) => write!(f, "received some data of size {}", data.len()), DownloadFinished(_) => write!(f, "download finished"), DownloadFailed(_) => write!(f, "download failed"), - SetProfile(name) => write!(f, "profile set to '{name}'"), SetSelfUpdate(mode) => write!(f, "auto-self-update mode set to '{mode}'"), LookingForToolchain(name) => write!(f, "looking for installed toolchain '{name}'"), ToolchainDirectory(path) => write!(f, "toolchain directory: '{}'", path.display()), diff --git a/tests/suite/cli_misc.rs b/tests/suite/cli_misc.rs index 286e5ff770..93a00d6ad3 100644 --- a/tests/suite/cli_misc.rs +++ b/tests/suite/cli_misc.rs @@ -1520,7 +1520,7 @@ error: override toolchain 'foo' is not installed: the +toolchain on the command .expect(["rustup", "+stable", "set", "profile", "minimal"]) .await .with_stderr(snapbox::str![[r#" -info: profile set to 'minimal' +info: profile set to minimal "#]]) .is_ok(); From 54248774d65300d6c8683ae90bd0c1bee546dba7 Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Thu, 2 Oct 2025 09:59:36 +0200 Subject: [PATCH 07/19] notifications: log directly when setting auto-self-update mode --- src/config.rs | 2 +- src/notifications.rs | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/config.rs b/src/config.rs index 4adeb909fe..a9b4967a2a 100644 --- a/src/config.rs +++ b/src/config.rs @@ -368,7 +368,7 @@ impl<'a> Cfg<'a> { s.auto_self_update = Some(mode); Ok(()) })?; - (self.notify_handler)(Notification::SetSelfUpdate(mode.as_str())); + info!("auto-self-update mode set to {}", mode.as_str()); Ok(()) } diff --git a/src/notifications.rs b/src/notifications.rs index 044ac87649..3bed50e65a 100644 --- a/src/notifications.rs +++ b/src/notifications.rs @@ -26,7 +26,6 @@ pub(crate) enum Notification<'a> { /// member, but the notification callback is already narrowed to /// utils::notifications by the time tar unpacking is called. SetDefaultBufferSize(usize), - SetSelfUpdate(&'a str), LookingForToolchain(&'a ToolchainDesc), ToolchainDirectory(&'a Path), UpdatingToolchain(&'a str), @@ -66,8 +65,7 @@ impl Notification<'_> { | ReadMetadataVersion(_) | InstalledToolchain(_) | UpdateHashMatches => NotificationLevel::Debug, - SetSelfUpdate(_) - | UsingExistingToolchain(_) + UsingExistingToolchain(_) | UninstallingToolchain(_) | UninstalledToolchain(_) | UpgradingMetadata(_, _) @@ -100,7 +98,6 @@ impl Display for Notification<'_> { DownloadDataReceived(data, _) => write!(f, "received some data of size {}", data.len()), DownloadFinished(_) => write!(f, "download finished"), DownloadFailed(_) => write!(f, "download failed"), - SetSelfUpdate(mode) => write!(f, "auto-self-update mode set to '{mode}'"), LookingForToolchain(name) => write!(f, "looking for installed toolchain '{name}'"), ToolchainDirectory(path) => write!(f, "toolchain directory: '{}'", path.display()), UpdatingToolchain(name) => write!(f, "updating existing install for '{name}'"), From 98609661e8e2b9f2f70c39ed3ccd8e600d0d41ad Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Thu, 2 Oct 2025 10:03:12 +0200 Subject: [PATCH 08/19] notifications: log directly when looking for toolchains --- src/config.rs | 4 ++-- src/notifications.rs | 3 --- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/config.rs b/src/config.rs index a9b4967a2a..880d9dee9d 100644 --- a/src/config.rs +++ b/src/config.rs @@ -8,7 +8,7 @@ use anyhow::{Context, Result, anyhow, bail}; use serde::Deserialize; use thiserror::Error as ThisError; use tokio_stream::StreamExt; -use tracing::{error, info, trace}; +use tracing::{debug, error, info, trace}; use crate::dist::AutoInstallMode; use crate::{ @@ -815,7 +815,7 @@ impl<'a> Cfg<'a> { force_non_host, )?; if verbose { - (self.notify_handler)(Notification::LookingForToolchain(toolchain)); + debug!("looking for installed toolchain {toolchain}"); } let components: Vec<_> = components.iter().map(AsRef::as_ref).collect(); let targets: Vec<_> = targets.iter().map(AsRef::as_ref).collect(); diff --git a/src/notifications.rs b/src/notifications.rs index 3bed50e65a..b30b9eacb2 100644 --- a/src/notifications.rs +++ b/src/notifications.rs @@ -26,7 +26,6 @@ pub(crate) enum Notification<'a> { /// member, but the notification callback is already narrowed to /// utils::notifications by the time tar unpacking is called. SetDefaultBufferSize(usize), - LookingForToolchain(&'a ToolchainDesc), ToolchainDirectory(&'a Path), UpdatingToolchain(&'a str), InstallingToolchain(&'a str), @@ -59,7 +58,6 @@ impl Notification<'_> { | DownloadFinished(_) | DownloadFailed(_) => NotificationLevel::Debug, ToolchainDirectory(_) - | LookingForToolchain(_) | InstallingToolchain(_) | UpdatingToolchain(_) | ReadMetadataVersion(_) @@ -98,7 +96,6 @@ impl Display for Notification<'_> { DownloadDataReceived(data, _) => write!(f, "received some data of size {}", data.len()), DownloadFinished(_) => write!(f, "download finished"), DownloadFailed(_) => write!(f, "download failed"), - LookingForToolchain(name) => write!(f, "looking for installed toolchain '{name}'"), ToolchainDirectory(path) => write!(f, "toolchain directory: '{}'", path.display()), UpdatingToolchain(name) => write!(f, "updating existing install for '{name}'"), InstallingToolchain(name) => write!(f, "installing toolchain '{name}'"), From d20aad5d06e029be98812d1cd3be15f9dc8bf61d Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Thu, 2 Oct 2025 10:04:40 +0200 Subject: [PATCH 09/19] notifications: log directly when using existing toolchains --- src/config.rs | 2 +- src/notifications.rs | 7 ++----- tests/suite/cli_exact.rs | 2 +- tests/suite/cli_misc.rs | 2 +- tests/suite/cli_rustup.rs | 4 ++-- tests/suite/cli_v1.rs | 2 +- tests/suite/cli_v2.rs | 2 +- 7 files changed, 9 insertions(+), 12 deletions(-) diff --git a/src/config.rs b/src/config.rs index 880d9dee9d..13140a857b 100644 --- a/src/config.rs +++ b/src/config.rs @@ -837,7 +837,7 @@ impl<'a> Cfg<'a> { } Ok(mut distributable) => { if verbose { - (self.notify_handler)(Notification::UsingExistingToolchain(toolchain)); + info!("using existing install for {toolchain}"); } let status = if !distributable.components_exist(&components, &targets)? { distributable.update(&components, &targets, profile).await? diff --git a/src/notifications.rs b/src/notifications.rs index b30b9eacb2..074e6ff6b2 100644 --- a/src/notifications.rs +++ b/src/notifications.rs @@ -4,7 +4,7 @@ use std::path::{Path, PathBuf}; use crate::dist::TargetTriple; use crate::settings::MetadataVersion; use crate::utils::units; -use crate::{dist::ToolchainDesc, toolchain::ToolchainName, utils::notify::NotificationLevel}; +use crate::{toolchain::ToolchainName, utils::notify::NotificationLevel}; #[derive(Debug)] pub(crate) enum Notification<'a> { @@ -30,7 +30,6 @@ pub(crate) enum Notification<'a> { UpdatingToolchain(&'a str), InstallingToolchain(&'a str), InstalledToolchain(&'a str), - UsingExistingToolchain(&'a ToolchainDesc), UninstallingToolchain(&'a ToolchainName), UninstalledToolchain(&'a ToolchainName), UpdateHashMatches, @@ -63,8 +62,7 @@ impl Notification<'_> { | ReadMetadataVersion(_) | InstalledToolchain(_) | UpdateHashMatches => NotificationLevel::Debug, - UsingExistingToolchain(_) - | UninstallingToolchain(_) + UninstallingToolchain(_) | UninstalledToolchain(_) | UpgradingMetadata(_, _) | MetadataUpgradeNotNeeded(_) => NotificationLevel::Info, @@ -100,7 +98,6 @@ impl Display for Notification<'_> { UpdatingToolchain(name) => write!(f, "updating existing install for '{name}'"), InstallingToolchain(name) => write!(f, "installing toolchain '{name}'"), InstalledToolchain(name) => write!(f, "toolchain '{name}' installed"), - UsingExistingToolchain(name) => write!(f, "using existing install for '{name}'"), UninstallingToolchain(name) => write!(f, "uninstalling toolchain '{name}'"), UninstalledToolchain(name) => write!(f, "toolchain '{name}' uninstalled"), UpdateHashMatches => write!(f, "toolchain is already up to date"), diff --git a/tests/suite/cli_exact.rs b/tests/suite/cli_exact.rs index f9af3c16a3..ce683817bb 100644 --- a/tests/suite/cli_exact.rs +++ b/tests/suite/cli_exact.rs @@ -355,7 +355,7 @@ async fn override_again() { .is_ok() .with_stdout(snapbox::str![[""]]) .with_stderr(snapbox::str![[r#" -info: override toolchain for '[CWD]' set to 'nightly-[HOST_TRIPLE]' +info: override toolchain for [CWD] set to nightly-[HOST_TRIPLE] "#]]); } diff --git a/tests/suite/cli_misc.rs b/tests/suite/cli_misc.rs index 93a00d6ad3..2830360683 100644 --- a/tests/suite/cli_misc.rs +++ b/tests/suite/cli_misc.rs @@ -636,7 +636,7 @@ async fn toolchains_are_resolved_early() { .await .with_stderr(snapbox::str![[r#" ... -info: using existing install for 'nightly-[HOST_TRIPLE]' +info: using existing install for nightly-[HOST_TRIPLE] ... "#]]) .is_ok(); diff --git a/tests/suite/cli_rustup.rs b/tests/suite/cli_rustup.rs index 7b1b0787dc..6f8626b7ac 100644 --- a/tests/suite/cli_rustup.rs +++ b/tests/suite/cli_rustup.rs @@ -322,7 +322,7 @@ async fn default_override() { .expect(["rustup", "default", "stable"]) .await .with_stderr(snapbox::str![[r#" -info: using existing install for 'stable-[HOST_TRIPLE]' +info: using existing install for stable-[HOST_TRIPLE] info: default toolchain set to stable-[HOST_TRIPLE] info: note that the toolchain 'nightly-[HOST_TRIPLE]' is currently in use (directory override for '[..]') @@ -1729,7 +1729,7 @@ rustc-[HOST_TRIPLE] .await .extend_redactions([("[TOOLCHAIN_FILE]", &toolchain_file)]) .with_stderr(snapbox::str![[r#" -info: using existing install for 'nightly-[HOST_TRIPLE]' +info: using existing install for nightly-[HOST_TRIPLE] info: the active toolchain `nightly-[HOST_TRIPLE]` has been installed info: it's active because: overridden by '[TOOLCHAIN_FILE]' diff --git a/tests/suite/cli_v1.rs b/tests/suite/cli_v1.rs index 194e6b73c3..3374d9e74a 100644 --- a/tests/suite/cli_v1.rs +++ b/tests/suite/cli_v1.rs @@ -147,7 +147,7 @@ async fn default_existing_toolchain() { .await .with_stderr(snapbox::str![[r#" ... -info: using existing install for 'nightly-[HOST_TRIPLE]' +info: using existing install for nightly-[HOST_TRIPLE] ... "#]]) .is_ok(); diff --git a/tests/suite/cli_v2.rs b/tests/suite/cli_v2.rs index 4538ccdad9..8179173313 100644 --- a/tests/suite/cli_v2.rs +++ b/tests/suite/cli_v2.rs @@ -196,7 +196,7 @@ async fn default_existing_toolchain() { .await .with_stderr(snapbox::str![[r#" ... -info: using existing install for 'nightly-[HOST_TRIPLE]' +info: using existing install for nightly-[HOST_TRIPLE] ... "#]]) .is_ok(); From 2bf043b8775a7f851a4842c4aee403dfe494e926 Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Thu, 2 Oct 2025 10:06:14 +0200 Subject: [PATCH 10/19] notifications: log the toolchain directory directly --- src/install.rs | 3 ++- src/notifications.rs | 5 +---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/install.rs b/src/install.rs index 2ab59b7d4b..7cd416531d 100644 --- a/src/install.rs +++ b/src/install.rs @@ -3,6 +3,7 @@ use std::path::{Path, PathBuf}; use anyhow::Result; +use tracing::debug; use crate::{ config::Cfg, @@ -55,7 +56,7 @@ impl InstallMethod<'_> { _ => nh(Notification::UpdatingToolchain(&self.dest_basename())), } - nh(Notification::ToolchainDirectory(&self.dest_path())); + debug!("toolchain directory: {}", self.dest_path().display()); let updated = self.run(&self.dest_path()).await?; let status = match updated { diff --git a/src/notifications.rs b/src/notifications.rs index 074e6ff6b2..3c8a3b77dc 100644 --- a/src/notifications.rs +++ b/src/notifications.rs @@ -26,7 +26,6 @@ pub(crate) enum Notification<'a> { /// member, but the notification callback is already narrowed to /// utils::notifications by the time tar unpacking is called. SetDefaultBufferSize(usize), - ToolchainDirectory(&'a Path), UpdatingToolchain(&'a str), InstallingToolchain(&'a str), InstalledToolchain(&'a str), @@ -56,8 +55,7 @@ impl Notification<'_> { | DownloadDataReceived(_, _) | DownloadFinished(_) | DownloadFailed(_) => NotificationLevel::Debug, - ToolchainDirectory(_) - | InstallingToolchain(_) + InstallingToolchain(_) | UpdatingToolchain(_) | ReadMetadataVersion(_) | InstalledToolchain(_) @@ -94,7 +92,6 @@ impl Display for Notification<'_> { DownloadDataReceived(data, _) => write!(f, "received some data of size {}", data.len()), DownloadFinished(_) => write!(f, "download finished"), DownloadFailed(_) => write!(f, "download failed"), - ToolchainDirectory(path) => write!(f, "toolchain directory: '{}'", path.display()), UpdatingToolchain(name) => write!(f, "updating existing install for '{name}'"), InstallingToolchain(name) => write!(f, "installing toolchain '{name}'"), InstalledToolchain(name) => write!(f, "toolchain '{name}' installed"), From ec5f760f99dc26a51ef404d71f484da9a092af72 Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Thu, 2 Oct 2025 10:08:29 +0200 Subject: [PATCH 11/19] notifications: log directly when installing toolchains --- src/install.rs | 4 ++-- src/notifications.rs | 12 +++--------- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/src/install.rs b/src/install.rs index 7cd416531d..c359beeecd 100644 --- a/src/install.rs +++ b/src/install.rs @@ -52,8 +52,8 @@ impl InstallMethod<'_> { | InstallMethod::Dist(DistOptions { old_date_version: None, .. - }) => nh(Notification::InstallingToolchain(&self.dest_basename())), - _ => nh(Notification::UpdatingToolchain(&self.dest_basename())), + }) => debug!("installing toolchain {}", self.dest_basename()), + _ => debug!("updating existing install for '{}'", self.dest_basename()), } debug!("toolchain directory: {}", self.dest_path().display()); diff --git a/src/notifications.rs b/src/notifications.rs index 3c8a3b77dc..900780baba 100644 --- a/src/notifications.rs +++ b/src/notifications.rs @@ -26,8 +26,6 @@ pub(crate) enum Notification<'a> { /// member, but the notification callback is already narrowed to /// utils::notifications by the time tar unpacking is called. SetDefaultBufferSize(usize), - UpdatingToolchain(&'a str), - InstallingToolchain(&'a str), InstalledToolchain(&'a str), UninstallingToolchain(&'a ToolchainName), UninstalledToolchain(&'a ToolchainName), @@ -55,11 +53,9 @@ impl Notification<'_> { | DownloadDataReceived(_, _) | DownloadFinished(_) | DownloadFailed(_) => NotificationLevel::Debug, - InstallingToolchain(_) - | UpdatingToolchain(_) - | ReadMetadataVersion(_) - | InstalledToolchain(_) - | UpdateHashMatches => NotificationLevel::Debug, + ReadMetadataVersion(_) | InstalledToolchain(_) | UpdateHashMatches => { + NotificationLevel::Debug + } UninstallingToolchain(_) | UninstalledToolchain(_) | UpgradingMetadata(_, _) @@ -92,8 +88,6 @@ impl Display for Notification<'_> { DownloadDataReceived(data, _) => write!(f, "received some data of size {}", data.len()), DownloadFinished(_) => write!(f, "download finished"), DownloadFailed(_) => write!(f, "download failed"), - UpdatingToolchain(name) => write!(f, "updating existing install for '{name}'"), - InstallingToolchain(name) => write!(f, "installing toolchain '{name}'"), InstalledToolchain(name) => write!(f, "toolchain '{name}' installed"), UninstallingToolchain(name) => write!(f, "uninstalling toolchain '{name}'"), UninstalledToolchain(name) => write!(f, "toolchain '{name}' uninstalled"), From 53ebff707167dc25793cf0c2d2b132fd543e1848 Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Thu, 2 Oct 2025 10:09:57 +0200 Subject: [PATCH 12/19] notifications: log directly when toolchain has been installed --- src/install.rs | 2 +- src/notifications.rs | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/install.rs b/src/install.rs index c359beeecd..648f91d66b 100644 --- a/src/install.rs +++ b/src/install.rs @@ -65,7 +65,7 @@ impl InstallMethod<'_> { UpdateStatus::Unchanged } true => { - nh(Notification::InstalledToolchain(&self.dest_basename())); + debug!("toolchain {} installed", self.dest_basename()); match self { InstallMethod::Dist(DistOptions { old_date_version: Some((_, v)), diff --git a/src/notifications.rs b/src/notifications.rs index 900780baba..a26a94132e 100644 --- a/src/notifications.rs +++ b/src/notifications.rs @@ -26,7 +26,6 @@ pub(crate) enum Notification<'a> { /// member, but the notification callback is already narrowed to /// utils::notifications by the time tar unpacking is called. SetDefaultBufferSize(usize), - InstalledToolchain(&'a str), UninstallingToolchain(&'a ToolchainName), UninstalledToolchain(&'a ToolchainName), UpdateHashMatches, @@ -53,7 +52,7 @@ impl Notification<'_> { | DownloadDataReceived(_, _) | DownloadFinished(_) | DownloadFailed(_) => NotificationLevel::Debug, - ReadMetadataVersion(_) | InstalledToolchain(_) | UpdateHashMatches => { + ReadMetadataVersion(_) | UpdateHashMatches => { NotificationLevel::Debug } UninstallingToolchain(_) @@ -88,7 +87,6 @@ impl Display for Notification<'_> { DownloadDataReceived(data, _) => write!(f, "received some data of size {}", data.len()), DownloadFinished(_) => write!(f, "download finished"), DownloadFailed(_) => write!(f, "download failed"), - InstalledToolchain(name) => write!(f, "toolchain '{name}' installed"), UninstallingToolchain(name) => write!(f, "uninstalling toolchain '{name}'"), UninstalledToolchain(name) => write!(f, "toolchain '{name}' uninstalled"), UpdateHashMatches => write!(f, "toolchain is already up to date"), From e6ef72784fa954eed381f221b44b9027a9879348 Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Thu, 2 Oct 2025 10:11:14 +0200 Subject: [PATCH 13/19] notifications: log directly when toolchain is up to date --- src/install.rs | 4 +--- src/notifications.rs | 6 +----- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/src/install.rs b/src/install.rs index 648f91d66b..fd2e3a8180 100644 --- a/src/install.rs +++ b/src/install.rs @@ -9,7 +9,6 @@ use crate::{ config::Cfg, dist::{self, DistOptions, prefix::InstallPrefix}, errors::RustupError, - notifications::Notification, toolchain::{CustomToolchainName, LocalToolchainName, Toolchain}, utils, }; @@ -45,7 +44,6 @@ impl InstallMethod<'_> { let _ = rayon::ThreadPoolBuilder::new() .num_threads(self.cfg().process.io_thread_count()?) .build_global(); - let nh = &self.cfg().notify_handler; match self { InstallMethod::Copy { .. } | InstallMethod::Link { .. } @@ -61,7 +59,7 @@ impl InstallMethod<'_> { let status = match updated { false => { - nh(Notification::UpdateHashMatches); + debug!("toolchain is already up to date"); UpdateStatus::Unchanged } true => { diff --git a/src/notifications.rs b/src/notifications.rs index a26a94132e..b645e78b93 100644 --- a/src/notifications.rs +++ b/src/notifications.rs @@ -28,7 +28,6 @@ pub(crate) enum Notification<'a> { SetDefaultBufferSize(usize), UninstallingToolchain(&'a ToolchainName), UninstalledToolchain(&'a ToolchainName), - UpdateHashMatches, UpgradingMetadata(MetadataVersion, MetadataVersion), MetadataUpgradeNotNeeded(MetadataVersion), ReadMetadataVersion(MetadataVersion), @@ -52,9 +51,7 @@ impl Notification<'_> { | DownloadDataReceived(_, _) | DownloadFinished(_) | DownloadFailed(_) => NotificationLevel::Debug, - ReadMetadataVersion(_) | UpdateHashMatches => { - NotificationLevel::Debug - } + ReadMetadataVersion(_) => NotificationLevel::Debug, UninstallingToolchain(_) | UninstalledToolchain(_) | UpgradingMetadata(_, _) @@ -89,7 +86,6 @@ impl Display for Notification<'_> { DownloadFailed(_) => write!(f, "download failed"), UninstallingToolchain(name) => write!(f, "uninstalling toolchain '{name}'"), UninstalledToolchain(name) => write!(f, "toolchain '{name}' uninstalled"), - UpdateHashMatches => write!(f, "toolchain is already up to date"), UpgradingMetadata(from_ver, to_ver) => write!( f, "upgrading metadata version from '{from_ver}' to '{to_ver}'" From fa4cbde7e15f7e1d69fe8a34818893461bd81fda Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Thu, 2 Oct 2025 10:13:16 +0200 Subject: [PATCH 14/19] notifications: log directly when uninstalling toolchains --- src/notifications.rs | 11 ++--------- src/toolchain.rs | 7 +++---- tests/suite/cli_misc.rs | 4 ++-- tests/suite/cli_v2.rs | 4 ++-- 4 files changed, 9 insertions(+), 17 deletions(-) diff --git a/src/notifications.rs b/src/notifications.rs index b645e78b93..3a79739fe1 100644 --- a/src/notifications.rs +++ b/src/notifications.rs @@ -3,8 +3,8 @@ use std::path::{Path, PathBuf}; use crate::dist::TargetTriple; use crate::settings::MetadataVersion; +use crate::utils::notify::NotificationLevel; use crate::utils::units; -use crate::{toolchain::ToolchainName, utils::notify::NotificationLevel}; #[derive(Debug)] pub(crate) enum Notification<'a> { @@ -26,8 +26,6 @@ pub(crate) enum Notification<'a> { /// member, but the notification callback is already narrowed to /// utils::notifications by the time tar unpacking is called. SetDefaultBufferSize(usize), - UninstallingToolchain(&'a ToolchainName), - UninstalledToolchain(&'a ToolchainName), UpgradingMetadata(MetadataVersion, MetadataVersion), MetadataUpgradeNotNeeded(MetadataVersion), ReadMetadataVersion(MetadataVersion), @@ -52,10 +50,7 @@ impl Notification<'_> { | DownloadFinished(_) | DownloadFailed(_) => NotificationLevel::Debug, ReadMetadataVersion(_) => NotificationLevel::Debug, - UninstallingToolchain(_) - | UninstalledToolchain(_) - | UpgradingMetadata(_, _) - | MetadataUpgradeNotNeeded(_) => NotificationLevel::Info, + UpgradingMetadata(_, _) | MetadataUpgradeNotNeeded(_) => NotificationLevel::Info, UpgradeRemovesToolchains | DuplicateToolchainFile { .. } => NotificationLevel::Warn, } } @@ -84,8 +79,6 @@ impl Display for Notification<'_> { DownloadDataReceived(data, _) => write!(f, "received some data of size {}", data.len()), DownloadFinished(_) => write!(f, "download finished"), DownloadFailed(_) => write!(f, "download failed"), - UninstallingToolchain(name) => write!(f, "uninstalling toolchain '{name}'"), - UninstalledToolchain(name) => write!(f, "toolchain '{name}' uninstalled"), UpgradingMetadata(from_ver, to_ver) => write!( f, "upgrading metadata version from '{from_ver}' to '{to_ver}'" diff --git a/src/toolchain.rs b/src/toolchain.rs index ad7183cfce..2fe7194ed4 100644 --- a/src/toolchain.rs +++ b/src/toolchain.rs @@ -28,7 +28,6 @@ use crate::{ prefix::InstallPrefix, }, env_var, install, - notifications::Notification, utils::{self, raw::open_dir_following_links}, }; @@ -544,7 +543,7 @@ impl<'a> Toolchain<'a> { }; let fs_modified = match Self::exists(cfg, &(&name).into())? { true => { - (cfg.notify_handler)(Notification::UninstallingToolchain(&name)); + info!("uninstalling toolchain {name}"); let installed_paths = match &name { ToolchainName::Custom(_) => Ok(vec![InstalledPath::Dir { path: &path }]), ToolchainName::Official(desc) => cfg.installed_paths(desc, &path), @@ -562,7 +561,7 @@ impl<'a> Toolchain<'a> { false => { // Might be a dangling symlink if path.is_symlink() { - (cfg.notify_handler)(Notification::UninstallingToolchain(&name)); + info!("uninstalling toolchain {name}"); fs::remove_dir_all(&path)?; true } else { @@ -579,7 +578,7 @@ impl<'a> Toolchain<'a> { }; if !path.is_symlink() && !path.exists() && fs_modified { - (cfg.notify_handler)(Notification::UninstalledToolchain(&name)); + info!("toolchain {name} uninstalled"); } Ok(()) } diff --git a/tests/suite/cli_misc.rs b/tests/suite/cli_misc.rs index 2830360683..a55cd30e00 100644 --- a/tests/suite/cli_misc.rs +++ b/tests/suite/cli_misc.rs @@ -1028,8 +1028,8 @@ test .expect(["rustup", "toolchain", "uninstall", "test"]) .await .with_stderr(snapbox::str![[r#" -info: uninstalling toolchain 'test' -info: toolchain 'test' uninstalled +info: uninstalling toolchain test +info: toolchain test uninstalled "#]]) .is_ok(); diff --git a/tests/suite/cli_v2.rs b/tests/suite/cli_v2.rs index 8179173313..edcef673a6 100644 --- a/tests/suite/cli_v2.rs +++ b/tests/suite/cli_v2.rs @@ -375,7 +375,7 @@ async fn remove_toolchain_ignore_trailing_slash() { .await .with_stderr(snapbox::str![[r#" ... -info: toolchain 'dev' uninstalled +info: toolchain dev uninstalled ... "#]]) .is_ok(); @@ -397,7 +397,7 @@ info: toolchain 'dev' uninstalled .await .with_stderr(snapbox::str![[r#" ... -info: toolchain 'nightly-[HOST_TRIPLE]' uninstalled +info: toolchain nightly-[HOST_TRIPLE] uninstalled ... "#]]) .is_ok(); From 73ae72d4808295cc917f85198830a915fb39d81d Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Thu, 2 Oct 2025 10:14:39 +0200 Subject: [PATCH 15/19] notifications: log directly when upgrading metadata version --- src/config.rs | 9 ++++----- src/notifications.rs | 7 +------ 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/src/config.rs b/src/config.rs index 13140a857b..f351f5cea2 100644 --- a/src/config.rs +++ b/src/config.rs @@ -448,11 +448,10 @@ impl<'a> Cfg<'a> { return Ok(()); } - (self.notify_handler)(Notification::UpgradingMetadata( - current_version, - MetadataVersion::default(), - )); - + info!( + "upgrading metadata version from {current_version} to {}", + MetadataVersion::default() + ); match current_version { MetadataVersion::V2 => { // The toolchain installation format changed. Just delete them all. diff --git a/src/notifications.rs b/src/notifications.rs index 3a79739fe1..8865bb1eb7 100644 --- a/src/notifications.rs +++ b/src/notifications.rs @@ -26,7 +26,6 @@ pub(crate) enum Notification<'a> { /// member, but the notification callback is already narrowed to /// utils::notifications by the time tar unpacking is called. SetDefaultBufferSize(usize), - UpgradingMetadata(MetadataVersion, MetadataVersion), MetadataUpgradeNotNeeded(MetadataVersion), ReadMetadataVersion(MetadataVersion), UpgradeRemovesToolchains, @@ -50,7 +49,7 @@ impl Notification<'_> { | DownloadFinished(_) | DownloadFailed(_) => NotificationLevel::Debug, ReadMetadataVersion(_) => NotificationLevel::Debug, - UpgradingMetadata(_, _) | MetadataUpgradeNotNeeded(_) => NotificationLevel::Info, + MetadataUpgradeNotNeeded(_) => NotificationLevel::Info, UpgradeRemovesToolchains | DuplicateToolchainFile { .. } => NotificationLevel::Warn, } } @@ -79,10 +78,6 @@ impl Display for Notification<'_> { DownloadDataReceived(data, _) => write!(f, "received some data of size {}", data.len()), DownloadFinished(_) => write!(f, "download finished"), DownloadFailed(_) => write!(f, "download failed"), - UpgradingMetadata(from_ver, to_ver) => write!( - f, - "upgrading metadata version from '{from_ver}' to '{to_ver}'" - ), MetadataUpgradeNotNeeded(ver) => { write!(f, "nothing to upgrade: metadata version is already '{ver}'") } From 3ab64dbef6cfcfc18fa557a0356406f3592f8da0 Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Thu, 2 Oct 2025 10:16:02 +0200 Subject: [PATCH 16/19] notifications: log directly when metadata upgrade is not needed --- src/config.rs | 2 +- src/notifications.rs | 5 ----- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/src/config.rs b/src/config.rs index f351f5cea2..28f670180c 100644 --- a/src/config.rs +++ b/src/config.rs @@ -444,7 +444,7 @@ impl<'a> Cfg<'a> { pub(crate) fn upgrade_data(&self) -> Result<()> { let current_version = self.settings_file.with(|s| Ok(s.version))?; if current_version == MetadataVersion::default() { - (self.notify_handler)(Notification::MetadataUpgradeNotNeeded(current_version)); + info!("nothing to upgrade: metadata version is already '{current_version}'"); return Ok(()); } diff --git a/src/notifications.rs b/src/notifications.rs index 8865bb1eb7..3eb4a3845f 100644 --- a/src/notifications.rs +++ b/src/notifications.rs @@ -26,7 +26,6 @@ pub(crate) enum Notification<'a> { /// member, but the notification callback is already narrowed to /// utils::notifications by the time tar unpacking is called. SetDefaultBufferSize(usize), - MetadataUpgradeNotNeeded(MetadataVersion), ReadMetadataVersion(MetadataVersion), UpgradeRemovesToolchains, /// Both `rust-toolchain` and `rust-toolchain.toml` exist within a directory @@ -49,7 +48,6 @@ impl Notification<'_> { | DownloadFinished(_) | DownloadFailed(_) => NotificationLevel::Debug, ReadMetadataVersion(_) => NotificationLevel::Debug, - MetadataUpgradeNotNeeded(_) => NotificationLevel::Info, UpgradeRemovesToolchains | DuplicateToolchainFile { .. } => NotificationLevel::Warn, } } @@ -78,9 +76,6 @@ impl Display for Notification<'_> { DownloadDataReceived(data, _) => write!(f, "received some data of size {}", data.len()), DownloadFinished(_) => write!(f, "download finished"), DownloadFailed(_) => write!(f, "download failed"), - MetadataUpgradeNotNeeded(ver) => { - write!(f, "nothing to upgrade: metadata version is already '{ver}'") - } ReadMetadataVersion(ver) => write!(f, "read metadata version: '{ver}'"), UpgradeRemovesToolchains => write!( f, From 16928e82984b8de0d36f72bf2ea305c604827bcc Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Thu, 2 Oct 2025 10:17:27 +0200 Subject: [PATCH 17/19] notifications: log directly when reading metadata version --- src/config.rs | 2 +- src/notifications.rs | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/src/config.rs b/src/config.rs index 28f670180c..cd0c9d815e 100644 --- a/src/config.rs +++ b/src/config.rs @@ -251,7 +251,7 @@ impl<'a> Cfg<'a> { let settings_file = SettingsFile::new(rustup_dir.join("settings.toml")); settings_file.with(|s| { - (notify_handler)(Notification::ReadMetadataVersion(s.version)); + debug!("read metadata version: {}", s.version); if s.version == MetadataVersion::default() { Ok(()) } else { diff --git a/src/notifications.rs b/src/notifications.rs index 3eb4a3845f..7f21878155 100644 --- a/src/notifications.rs +++ b/src/notifications.rs @@ -2,7 +2,6 @@ use std::fmt::{self, Display}; use std::path::{Path, PathBuf}; use crate::dist::TargetTriple; -use crate::settings::MetadataVersion; use crate::utils::notify::NotificationLevel; use crate::utils::units; @@ -26,7 +25,6 @@ pub(crate) enum Notification<'a> { /// member, but the notification callback is already narrowed to /// utils::notifications by the time tar unpacking is called. SetDefaultBufferSize(usize), - ReadMetadataVersion(MetadataVersion), UpgradeRemovesToolchains, /// Both `rust-toolchain` and `rust-toolchain.toml` exist within a directory DuplicateToolchainFile { @@ -47,7 +45,6 @@ impl Notification<'_> { | DownloadDataReceived(_, _) | DownloadFinished(_) | DownloadFailed(_) => NotificationLevel::Debug, - ReadMetadataVersion(_) => NotificationLevel::Debug, UpgradeRemovesToolchains | DuplicateToolchainFile { .. } => NotificationLevel::Warn, } } @@ -76,7 +73,6 @@ impl Display for Notification<'_> { DownloadDataReceived(data, _) => write!(f, "received some data of size {}", data.len()), DownloadFinished(_) => write!(f, "download finished"), DownloadFailed(_) => write!(f, "download failed"), - ReadMetadataVersion(ver) => write!(f, "read metadata version: '{ver}'"), UpgradeRemovesToolchains => write!( f, "this upgrade will remove all existing toolchains. you will need to reinstall them" From 6bfa3f7ed6dab651be9195aec96e62c9f2ba0df5 Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Thu, 2 Oct 2025 10:18:51 +0200 Subject: [PATCH 18/19] notifications: log directly on metadata upgrades that remove toolchains --- src/config.rs | 6 ++++-- src/notifications.rs | 7 +------ 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/config.rs b/src/config.rs index cd0c9d815e..03db3fc607 100644 --- a/src/config.rs +++ b/src/config.rs @@ -8,7 +8,7 @@ use anyhow::{Context, Result, anyhow, bail}; use serde::Deserialize; use thiserror::Error as ThisError; use tokio_stream::StreamExt; -use tracing::{debug, error, info, trace}; +use tracing::{debug, error, info, trace, warn}; use crate::dist::AutoInstallMode; use crate::{ @@ -455,7 +455,9 @@ impl<'a> Cfg<'a> { match current_version { MetadataVersion::V2 => { // The toolchain installation format changed. Just delete them all. - (self.notify_handler)(Notification::UpgradeRemovesToolchains); + warn!( + "this upgrade will remove all existing toolchains; you will need to reinstall them" + ); let dirs = utils::read_dir("toolchains", &self.toolchains_dir)?; for dir in dirs { diff --git a/src/notifications.rs b/src/notifications.rs index 7f21878155..664e8ade98 100644 --- a/src/notifications.rs +++ b/src/notifications.rs @@ -25,7 +25,6 @@ pub(crate) enum Notification<'a> { /// member, but the notification callback is already narrowed to /// utils::notifications by the time tar unpacking is called. SetDefaultBufferSize(usize), - UpgradeRemovesToolchains, /// Both `rust-toolchain` and `rust-toolchain.toml` exist within a directory DuplicateToolchainFile { rust_toolchain: &'a Path, @@ -45,7 +44,7 @@ impl Notification<'_> { | DownloadDataReceived(_, _) | DownloadFinished(_) | DownloadFailed(_) => NotificationLevel::Debug, - UpgradeRemovesToolchains | DuplicateToolchainFile { .. } => NotificationLevel::Warn, + DuplicateToolchainFile { .. } => NotificationLevel::Warn, } } } @@ -73,10 +72,6 @@ impl Display for Notification<'_> { DownloadDataReceived(data, _) => write!(f, "received some data of size {}", data.len()), DownloadFinished(_) => write!(f, "download finished"), DownloadFailed(_) => write!(f, "download failed"), - UpgradeRemovesToolchains => write!( - f, - "this upgrade will remove all existing toolchains. you will need to reinstall them" - ), DuplicateToolchainFile { rust_toolchain, rust_toolchain_toml, From 6a313cd1af1877bef7961d683f9d1ed14d36adce Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Thu, 2 Oct 2025 10:22:53 +0200 Subject: [PATCH 19/19] notifications: log directly on duplicate toolchain files --- src/config.rs | 16 +++++++++++----- src/notifications.rs | 22 ---------------------- tests/suite/cli_rustup.rs | 2 +- 3 files changed, 12 insertions(+), 28 deletions(-) diff --git a/src/config.rs b/src/config.rs index 03db3fc607..9f238038d0 100644 --- a/src/config.rs +++ b/src/config.rs @@ -571,7 +571,6 @@ impl<'a> Cfg<'a> { dir: &Path, settings: &Settings, ) -> Result> { - let notify = self.notify_handler.as_ref(); let mut dir = Some(dir); while let Some(d) = dir { @@ -609,10 +608,17 @@ impl<'a> Cfg<'a> { (Ok(contents), Ok(_)) => { // both `rust-toolchain` and `rust-toolchain.toml` exist - notify(Notification::DuplicateToolchainFile { - rust_toolchain: &path_rust_toolchain, - rust_toolchain_toml: &path_rust_toolchain_toml, - }); + warn!( + "both {} and {} exist; using contents of {0}", + path_rust_toolchain + .canonicalize() + .unwrap_or_else(|_| PathBuf::from(&path_rust_toolchain)) + .display(), + path_rust_toolchain_toml + .canonicalize() + .unwrap_or_else(|_| PathBuf::from(&path_rust_toolchain_toml)) + .display(), + ); (path_rust_toolchain, Ok(contents), ParseMode::Both) } diff --git a/src/notifications.rs b/src/notifications.rs index 664e8ade98..6625a36cbe 100644 --- a/src/notifications.rs +++ b/src/notifications.rs @@ -1,5 +1,4 @@ use std::fmt::{self, Display}; -use std::path::{Path, PathBuf}; use crate::dist::TargetTriple; use crate::utils::notify::NotificationLevel; @@ -25,11 +24,6 @@ pub(crate) enum Notification<'a> { /// member, but the notification callback is already narrowed to /// utils::notifications by the time tar unpacking is called. SetDefaultBufferSize(usize), - /// Both `rust-toolchain` and `rust-toolchain.toml` exist within a directory - DuplicateToolchainFile { - rust_toolchain: &'a Path, - rust_toolchain_toml: &'a Path, - }, } impl Notification<'_> { @@ -44,7 +38,6 @@ impl Notification<'_> { | DownloadDataReceived(_, _) | DownloadFinished(_) | DownloadFailed(_) => NotificationLevel::Debug, - DuplicateToolchainFile { .. } => NotificationLevel::Warn, } } } @@ -72,21 +65,6 @@ impl Display for Notification<'_> { DownloadDataReceived(data, _) => write!(f, "received some data of size {}", data.len()), DownloadFinished(_) => write!(f, "download finished"), DownloadFailed(_) => write!(f, "download failed"), - DuplicateToolchainFile { - rust_toolchain, - rust_toolchain_toml, - } => write!( - f, - "both `{0}` and `{1}` exist. Using `{0}`", - rust_toolchain - .canonicalize() - .unwrap_or_else(|_| PathBuf::from(rust_toolchain)) - .display(), - rust_toolchain_toml - .canonicalize() - .unwrap_or_else(|_| PathBuf::from(rust_toolchain_toml)) - .display(), - ), } } } diff --git a/tests/suite/cli_rustup.rs b/tests/suite/cli_rustup.rs index 6f8626b7ac..d82aba33dc 100644 --- a/tests/suite/cli_rustup.rs +++ b/tests/suite/cli_rustup.rs @@ -3692,7 +3692,7 @@ async fn warn_on_duplicate_rust_toolchain_file() { .extend_redactions([("[CWD]", &cwd.canonicalize().unwrap())]) .with_stderr(snapbox::str![[r#" ... -warn: both `[CWD]/rust-toolchain` and `[CWD]/rust-toolchain.toml` exist. Using `[CWD]/rust-toolchain` +warn: both [CWD]/rust-toolchain and [CWD]/rust-toolchain.toml exist; using contents of [CWD]/rust-toolchain ... "#]]) .is_ok();