Skip to content

Commit 00f48fe

Browse files
committed
Parse version numbers optionally without the patch version specified
Fixes rust-lang#794.
1 parent 71f09c5 commit 00f48fe

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/dist/dist.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ static TOOLCHAIN_CHANNELS: &[&str] = &[
2727
"nightly",
2828
"beta",
2929
"stable",
30-
// Allow from 1.0.0 through to 9.999.99
31-
r"\d{1}\.\d{1,3}\.\d{1,2}",
30+
// Allow from 1.0.0 through to 9.999.99 with optional patch version
31+
r"\d{1}\.\d{1,3}(?:\.\d{1,2})?",
3232
];
3333

3434
#[derive(Debug, PartialEq)]
@@ -951,6 +951,7 @@ mod tests {
951951
("nightly", ("nightly", None, None)),
952952
("beta", ("beta", None, None)),
953953
("stable", ("stable", None, None)),
954+
("0.0", ("0.0", None, None)),
954955
("0.0.0", ("0.0.0", None, None)),
955956
("0.0.0--", ("0.0.0", None, Some("-"))), // possibly a bug?
956957
("9.999.99", ("9.999.99", None, None)),
@@ -986,7 +987,7 @@ mod tests {
986987
assert_eq!(parsed.unwrap(), expected, "input: `{}`", input);
987988
}
988989

989-
let failure_cases = vec!["anything", "00.0000.000", "3", "3.4", "", "--", "0.0.0-"];
990+
let failure_cases = vec!["anything", "00.0000.000", "3", "", "--", "0.0.0-"];
990991

991992
for input in failure_cases {
992993
let parsed = input.parse::<ParsedToolchainDesc>();

0 commit comments

Comments
 (0)