summaryrefslogtreecommitdiffstats
path: root/src/tools/tidy/src/features/version.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:03:36 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:03:36 +0000
commit17d40c6057c88f4c432b0d7bac88e1b84cb7e67f (patch)
tree3f66c4a5918660bb8a758ab6cda5ff8ee4f6cdcd /src/tools/tidy/src/features/version.rs
parentAdding upstream version 1.64.0+dfsg1. (diff)
downloadrustc-f7f0cc2a5d72e2c61c1f6900e70eec992bea4273.tar.xz
rustc-f7f0cc2a5d72e2c61c1f6900e70eec992bea4273.zip
Adding upstream version 1.65.0+dfsg1.upstream/1.65.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/tools/tidy/src/features/version.rs')
-rw-r--r--src/tools/tidy/src/features/version.rs19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/tools/tidy/src/features/version.rs b/src/tools/tidy/src/features/version.rs
index 620be2f98..0830c226c 100644
--- a/src/tools/tidy/src/features/version.rs
+++ b/src/tools/tidy/src/features/version.rs
@@ -5,14 +5,22 @@ use std::str::FromStr;
#[cfg(test)]
mod tests;
+pub const VERSION_PLACEHOLDER: &str = "CURRENT_RUSTC_VERSION";
+
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
-pub struct Version {
- parts: [u32; 3],
+pub enum Version {
+ Explicit { parts: [u32; 3] },
+ CurrentPlaceholder,
}
impl fmt::Display for Version {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
- f.pad(&format!("{}.{}.{}", self.parts[0], self.parts[1], self.parts[2]))
+ match self {
+ Version::Explicit { parts } => {
+ f.pad(&format!("{}.{}.{}", parts[0], parts[1], parts[2]))
+ }
+ Version::CurrentPlaceholder => f.pad(&format!("CURRENT")),
+ }
}
}
@@ -32,6 +40,9 @@ impl FromStr for Version {
type Err = ParseVersionError;
fn from_str(s: &str) -> Result<Self, Self::Err> {
+ if s == VERSION_PLACEHOLDER {
+ return Ok(Version::CurrentPlaceholder);
+ }
let mut iter = s.split('.').map(|part| Ok(part.parse()?));
let mut part = || iter.next().unwrap_or(Err(ParseVersionError::WrongNumberOfParts));
@@ -43,6 +54,6 @@ impl FromStr for Version {
return Err(ParseVersionError::WrongNumberOfParts);
}
- Ok(Self { parts })
+ Ok(Version::Explicit { parts })
}
}