Skip to content

Commit f10ee11

Browse files
committed
Fix build.rs failing with a rustc built from a tarball
Fixes #1601
1 parent bd48043 commit f10ee11

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

build.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,16 @@ fn rustc_minor_nightly() -> Option<(u32, bool)> {
103103
}
104104

105105
let minor = pieces.next();
106-
let nightly_raw = otry!(otry!(pieces.next()).split('-').nth(1));
107-
let nightly =
108-
nightly_raw.starts_with("dev") || nightly_raw.starts_with("nightly");
106+
107+
// If `rustc` was built from a tarball, its version string
108+
// will have neither a git hash nor a commit date
109+
// (e.g. "rustc 1.39.0"). Treat this case as non-nightly,
110+
// since a nightly build should either come from CI
111+
// or a git checkout
112+
let nightly_raw = otry!(pieces.next()).split('-').nth(1);
113+
let nightly = nightly_raw
114+
.map(|raw| raw.starts_with("dev") || raw.starts_with("nightly"))
115+
.unwrap_or(false);
109116
let minor = otry!(otry!(minor).parse().ok());
110117

111118
Some((minor, nightly))

0 commit comments

Comments
 (0)