Report the actual error when failing to get the rustc version
This should help with pinpointing the issue in rust-lang/crater#663.
This commit is contained in:
parent
8b6bfd7d9f
commit
40c19428ce
16
build.rs
16
build.rs
|
@ -6,7 +6,7 @@ fn main() {
|
||||||
// Avoid unnecessary re-building.
|
// Avoid unnecessary re-building.
|
||||||
println!("cargo:rerun-if-changed=build.rs");
|
println!("cargo:rerun-if-changed=build.rs");
|
||||||
|
|
||||||
let (rustc_minor_ver, is_nightly) = rustc_minor_nightly().expect("Failed to get rustc version");
|
let (rustc_minor_ver, is_nightly) = rustc_minor_nightly();
|
||||||
let rustc_dep_of_std = env::var("CARGO_FEATURE_RUSTC_DEP_OF_STD").is_ok();
|
let rustc_dep_of_std = env::var("CARGO_FEATURE_RUSTC_DEP_OF_STD").is_ok();
|
||||||
let align_cargo_feature = env::var("CARGO_FEATURE_ALIGN").is_ok();
|
let align_cargo_feature = env::var("CARGO_FEATURE_ALIGN").is_ok();
|
||||||
let const_extern_fn_cargo_feature = env::var("CARGO_FEATURE_CONST_EXTERN_FN").is_ok();
|
let const_extern_fn_cargo_feature = env::var("CARGO_FEATURE_CONST_EXTERN_FN").is_ok();
|
||||||
|
@ -112,23 +112,27 @@ fn main() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn rustc_minor_nightly() -> Option<(u32, bool)> {
|
fn rustc_minor_nightly() -> (u32, bool) {
|
||||||
macro_rules! otry {
|
macro_rules! otry {
|
||||||
($e:expr) => {
|
($e:expr) => {
|
||||||
match $e {
|
match $e {
|
||||||
Some(e) => e,
|
Some(e) => e,
|
||||||
None => return None,
|
None => panic!("Failed to get rustc version"),
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
let rustc = otry!(env::var_os("RUSTC"));
|
let rustc = otry!(env::var_os("RUSTC"));
|
||||||
let output = otry!(Command::new(rustc).arg("--version").output().ok());
|
let output = Command::new(rustc)
|
||||||
|
.arg("--version")
|
||||||
|
.output()
|
||||||
|
.ok()
|
||||||
|
.expect("Failed to get rustc version");
|
||||||
let version = otry!(str::from_utf8(&output.stdout).ok());
|
let version = otry!(str::from_utf8(&output.stdout).ok());
|
||||||
let mut pieces = version.split('.');
|
let mut pieces = version.split('.');
|
||||||
|
|
||||||
if pieces.next() != Some("rustc 1") {
|
if pieces.next() != Some("rustc 1") {
|
||||||
return None;
|
panic!("Failed to get rustc version");
|
||||||
}
|
}
|
||||||
|
|
||||||
let minor = pieces.next();
|
let minor = pieces.next();
|
||||||
|
@ -144,7 +148,7 @@ fn rustc_minor_nightly() -> Option<(u32, bool)> {
|
||||||
.unwrap_or(false);
|
.unwrap_or(false);
|
||||||
let minor = otry!(otry!(minor).parse().ok());
|
let minor = otry!(otry!(minor).parse().ok());
|
||||||
|
|
||||||
Some((minor, nightly))
|
(minor, nightly)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn which_freebsd() -> Option<i32> {
|
fn which_freebsd() -> Option<i32> {
|
||||||
|
|
Loading…
Reference in a new issue