Skip to content

Commit 19802f8

Browse files
committed
rustc_tools_util: clean up pedantic clippy warnings
1 parent e840006 commit 19802f8

File tree

1 file changed

+27
-31
lines changed

1 file changed

+27
-31
lines changed

rustc_tools_util/src/lib.rs

Lines changed: 27 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -39,48 +39,44 @@ pub struct VersionInfo {
3939
}
4040

4141
impl std::fmt::Display for VersionInfo {
42-
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
43-
match self.commit_hash {
44-
Some(_) => {
45-
write!(
46-
f,
47-
"{} {}.{}.{} ({} {})",
48-
self.crate_name,
49-
self.major,
50-
self.minor,
51-
self.patch,
52-
self.commit_hash.clone().unwrap_or_default().trim(),
53-
self.commit_date.clone().unwrap_or_default().trim(),
54-
)?;
55-
},
56-
None => {
57-
write!(f, "{} {}.{}.{}", self.crate_name, self.major, self.minor, self.patch)?;
58-
},
59-
};
42+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
43+
if self.commit_hash.is_some() {
44+
write!(
45+
f,
46+
"{} {}.{}.{} ({} {})",
47+
self.crate_name,
48+
self.major,
49+
self.minor,
50+
self.patch,
51+
self.commit_hash.clone().unwrap_or_default().trim(),
52+
self.commit_date.clone().unwrap_or_default().trim(),
53+
)?;
54+
} else {
55+
write!(f, "{} {}.{}.{}", self.crate_name, self.major, self.minor, self.patch)?;
56+
}
57+
6058
Ok(())
6159
}
6260
}
6361

6462
impl std::fmt::Debug for VersionInfo {
65-
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
63+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
6664
write!(
6765
f,
6866
"VersionInfo {{ crate_name: \"{}\", major: {}, minor: {}, patch: {}",
6967
self.crate_name, self.major, self.minor, self.patch,
7068
)?;
71-
match self.commit_hash {
72-
Some(_) => {
73-
write!(
74-
f,
75-
", commit_hash: \"{}\", commit_date: \"{}\" }}",
76-
self.commit_hash.clone().unwrap_or_default().trim(),
77-
self.commit_date.clone().unwrap_or_default().trim()
78-
)?;
79-
},
80-
None => {
81-
write!(f, " }}")?;
82-
},
69+
if self.commit_hash.is_some() {
70+
write!(
71+
f,
72+
", commit_hash: \"{}\", commit_date: \"{}\" }}",
73+
self.commit_hash.clone().unwrap_or_default().trim(),
74+
self.commit_date.clone().unwrap_or_default().trim()
75+
)?;
76+
} else {
77+
write!(f, " }}")?;
8378
}
79+
8480
Ok(())
8581
}
8682
}

0 commit comments

Comments
 (0)