Skip to content

Commit 202db3e

Browse files
committed
rustc_tools_util: don't hardcode crate name
1 parent 63a46b1 commit 202db3e

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

rustc_tools_util/src/lib.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ macro_rules! get_version_info {
88
let major = env!("CARGO_PKG_VERSION_MAJOR").parse::<u8>().unwrap();
99
let minor = env!("CARGO_PKG_VERSION_MINOR").parse::<u8>().unwrap();
1010
let patch = env!("CARGO_PKG_VERSION_PATCH").parse::<u16>().unwrap();
11+
let crate_name = String::from(env!("CARGO_PKG_NAME"));
1112

1213
let host_compiler = $crate::get_channel();
1314
let commit_hash = option_env!("GIT_HASH").map(|s| s.to_string());
@@ -20,6 +21,7 @@ macro_rules! get_version_info {
2021
host_compiler,
2122
commit_hash,
2223
commit_date,
24+
crate_name,
2325
}
2426
}};
2527
}
@@ -32,6 +34,7 @@ pub struct VersionInfo {
3234
pub host_compiler: Option<String>,
3335
pub commit_hash: Option<String>,
3436
pub commit_date: Option<String>,
37+
pub crate_name: String,
3538
}
3639

3740
impl std::fmt::Display for VersionInfo {
@@ -40,7 +43,8 @@ impl std::fmt::Display for VersionInfo {
4043
Some(_) => {
4144
write!(
4245
f,
43-
"clippy {}.{}.{} ({} {})",
46+
"{} {}.{}.{} ({} {})",
47+
self.crate_name,
4448
self.major,
4549
self.minor,
4650
self.patch,
@@ -49,7 +53,7 @@ impl std::fmt::Display for VersionInfo {
4953
)?;
5054
},
5155
None => {
52-
write!(f, "clippy {}.{}.{}", self.major, self.minor, self.patch)?;
56+
write!(f, "{} {}.{}.{}", self.crate_name, self.major, self.minor, self.patch)?;
5357
},
5458
};
5559
Ok(())

0 commit comments

Comments
 (0)