summaryrefslogtreecommitdiffstats
path: root/vendor/rustversion/build/rustc.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:57:31 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:57:31 +0000
commitdc0db358abe19481e475e10c32149b53370f1a1c (patch)
treeab8ce99c4b255ce46f99ef402c27916055b899ee /vendor/rustversion/build/rustc.rs
parentReleasing progress-linux version 1.71.1+dfsg1-2~progress7.99u1. (diff)
downloadrustc-dc0db358abe19481e475e10c32149b53370f1a1c.tar.xz
rustc-dc0db358abe19481e475e10c32149b53370f1a1c.zip
Merging upstream version 1.72.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/rustversion/build/rustc.rs')
-rw-r--r--vendor/rustversion/build/rustc.rs20
1 files changed, 16 insertions, 4 deletions
diff --git a/vendor/rustversion/build/rustc.rs b/vendor/rustversion/build/rustc.rs
index dfc6a0516..71a830b93 100644
--- a/vendor/rustversion/build/rustc.rs
+++ b/vendor/rustversion/build/rustc.rs
@@ -1,6 +1,12 @@
use self::Channel::*;
use std::fmt::{self, Debug};
+pub enum ParseResult {
+ Success(Version),
+ OopsClippy,
+ Unrecognized,
+}
+
#[cfg_attr(test, derive(PartialEq))]
pub struct Version {
pub minor: u16,
@@ -23,14 +29,20 @@ pub struct Date {
pub day: u8,
}
-pub fn parse(string: &str) -> Option<Version> {
- let last_line = string.lines().last().unwrap_or(&string);
+pub fn parse(string: &str) -> ParseResult {
+ let last_line = string.lines().last().unwrap_or(string);
let mut words = last_line.trim().split(' ');
- if words.next()? != "rustc" {
- return None;
+ match words.next() {
+ Some("rustc") => {}
+ Some(word) if word.starts_with("clippy") => return ParseResult::OopsClippy,
+ Some(_) | None => return ParseResult::Unrecognized,
}
+ parse_words(&mut words).map_or(ParseResult::Unrecognized, ParseResult::Success)
+}
+
+fn parse_words(words: &mut dyn Iterator<Item = &str>) -> Option<Version> {
let mut version_channel = words.next()?.split('-');
let version = version_channel.next()?;
let channel = version_channel.next();