Skip to content

Commit bbf929d

Browse files
committed
Auto merge of #3000 - bjorn3:report_rustc_version_errors, r=JohnTitor
Report the actual error when failing to get the rustc version This should help with pinpointing the issue in rust-lang/crater#663.
2 parents 8b6bfd7 + 40c1942 commit bbf929d

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

build.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ fn main() {
66
// Avoid unnecessary re-building.
77
println!("cargo:rerun-if-changed=build.rs");
88

9-
let (rustc_minor_ver, is_nightly) = rustc_minor_nightly().expect("Failed to get rustc version");
9+
let (rustc_minor_ver, is_nightly) = rustc_minor_nightly();
1010
let rustc_dep_of_std = env::var("CARGO_FEATURE_RUSTC_DEP_OF_STD").is_ok();
1111
let align_cargo_feature = env::var("CARGO_FEATURE_ALIGN").is_ok();
1212
let const_extern_fn_cargo_feature = env::var("CARGO_FEATURE_CONST_EXTERN_FN").is_ok();
@@ -112,23 +112,27 @@ fn main() {
112112
}
113113
}
114114

115-
fn rustc_minor_nightly() -> Option<(u32, bool)> {
115+
fn rustc_minor_nightly() -> (u32, bool) {
116116
macro_rules! otry {
117117
($e:expr) => {
118118
match $e {
119119
Some(e) => e,
120-
None => return None,
120+
None => panic!("Failed to get rustc version"),
121121
}
122122
};
123123
}
124124

125125
let rustc = otry!(env::var_os("RUSTC"));
126-
let output = otry!(Command::new(rustc).arg("--version").output().ok());
126+
let output = Command::new(rustc)
127+
.arg("--version")
128+
.output()
129+
.ok()
130+
.expect("Failed to get rustc version");
127131
let version = otry!(str::from_utf8(&output.stdout).ok());
128132
let mut pieces = version.split('.');
129133

130134
if pieces.next() != Some("rustc 1") {
131-
return None;
135+
panic!("Failed to get rustc version");
132136
}
133137

134138
let minor = pieces.next();
@@ -144,7 +148,7 @@ fn rustc_minor_nightly() -> Option<(u32, bool)> {
144148
.unwrap_or(false);
145149
let minor = otry!(otry!(minor).parse().ok());
146150

147-
Some((minor, nightly))
151+
(minor, nightly)
148152
}
149153

150154
fn which_freebsd() -> Option<i32> {

0 commit comments

Comments
 (0)