Skip to content

Commit 47d39ac

Browse files
committed
notifications: log directly on duplicate toolchain files
1 parent 3872e46 commit 47d39ac

File tree

3 files changed

+12
-28
lines changed

3 files changed

+12
-28
lines changed

src/config.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,6 @@ impl<'a> Cfg<'a> {
571571
dir: &Path,
572572
settings: &Settings,
573573
) -> Result<Option<(OverrideCfg, ActiveReason)>> {
574-
let notify = self.notify_handler.as_ref();
575574
let mut dir = Some(dir);
576575

577576
while let Some(d) = dir {
@@ -609,10 +608,17 @@ impl<'a> Cfg<'a> {
609608
(Ok(contents), Ok(_)) => {
610609
// both `rust-toolchain` and `rust-toolchain.toml` exist
611610

612-
notify(Notification::DuplicateToolchainFile {
613-
rust_toolchain: &path_rust_toolchain,
614-
rust_toolchain_toml: &path_rust_toolchain_toml,
615-
});
611+
warn!(
612+
"both {} and {} exist; using contents of {0}",
613+
path_rust_toolchain
614+
.canonicalize()
615+
.unwrap_or_else(|_| PathBuf::from(&path_rust_toolchain))
616+
.display(),
617+
path_rust_toolchain_toml
618+
.canonicalize()
619+
.unwrap_or_else(|_| PathBuf::from(&path_rust_toolchain_toml))
620+
.display(),
621+
);
616622

617623
(path_rust_toolchain, Ok(contents), ParseMode::Both)
618624
}

src/notifications.rs

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use std::fmt::{self, Display};
2-
use std::path::{Path, PathBuf};
32

43
use crate::dist::TargetTriple;
54
use crate::utils::notify::NotificationLevel;
@@ -25,11 +24,6 @@ pub(crate) enum Notification<'a> {
2524
/// member, but the notification callback is already narrowed to
2625
/// utils::notifications by the time tar unpacking is called.
2726
SetDefaultBufferSize(usize),
28-
/// Both `rust-toolchain` and `rust-toolchain.toml` exist within a directory
29-
DuplicateToolchainFile {
30-
rust_toolchain: &'a Path,
31-
rust_toolchain_toml: &'a Path,
32-
},
3327
}
3428

3529
impl Notification<'_> {
@@ -44,7 +38,6 @@ impl Notification<'_> {
4438
| DownloadDataReceived(_, _)
4539
| DownloadFinished(_)
4640
| DownloadFailed(_) => NotificationLevel::Debug,
47-
DuplicateToolchainFile { .. } => NotificationLevel::Warn,
4841
}
4942
}
5043
}
@@ -72,21 +65,6 @@ impl Display for Notification<'_> {
7265
DownloadDataReceived(data, _) => write!(f, "received some data of size {}", data.len()),
7366
DownloadFinished(_) => write!(f, "download finished"),
7467
DownloadFailed(_) => write!(f, "download failed"),
75-
DuplicateToolchainFile {
76-
rust_toolchain,
77-
rust_toolchain_toml,
78-
} => write!(
79-
f,
80-
"both `{0}` and `{1}` exist. Using `{0}`",
81-
rust_toolchain
82-
.canonicalize()
83-
.unwrap_or_else(|_| PathBuf::from(rust_toolchain))
84-
.display(),
85-
rust_toolchain_toml
86-
.canonicalize()
87-
.unwrap_or_else(|_| PathBuf::from(rust_toolchain_toml))
88-
.display(),
89-
),
9068
}
9169
}
9270
}

tests/suite/cli_rustup.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3692,7 +3692,7 @@ async fn warn_on_duplicate_rust_toolchain_file() {
36923692
.extend_redactions([("[CWD]", &cwd.canonicalize().unwrap())])
36933693
.with_stderr(snapbox::str![[r#"
36943694
...
3695-
warn: both `[CWD]/rust-toolchain` and `[CWD]/rust-toolchain.toml` exist. Using `[CWD]/rust-toolchain`
3695+
warn: both [CWD]/rust-toolchain and [CWD]/rust-toolchain.toml exist; using contents of [CWD]/rust-toolchain
36963696
...
36973697
"#]])
36983698
.is_ok();

0 commit comments

Comments
 (0)