mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-06-13 07:51:03 +00:00
Make serde_test build script buildable with older rustc
This commit is contained in:
+23
-5
@@ -1,6 +1,6 @@
|
|||||||
use std::env;
|
use std::env;
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
use std::str;
|
use std::str::{self, FromStr};
|
||||||
|
|
||||||
// The rustc-cfg strings below are *not* public API. Please let us know by
|
// The rustc-cfg strings below are *not* public API. Please let us know by
|
||||||
// opening a GitHub issue if your build environment requires some way to enable
|
// opening a GitHub issue if your build environment requires some way to enable
|
||||||
@@ -19,12 +19,30 @@ fn main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn rustc_minor_version() -> Option<u32> {
|
fn rustc_minor_version() -> Option<u32> {
|
||||||
let rustc = env::var_os("RUSTC")?;
|
let rustc = match env::var_os("RUSTC") {
|
||||||
let output = Command::new(rustc).arg("--version").output().ok()?;
|
Some(rustc) => rustc,
|
||||||
let version = str::from_utf8(&output.stdout).ok()?;
|
None => return None,
|
||||||
|
};
|
||||||
|
|
||||||
|
let output = match Command::new(rustc).arg("--version").output() {
|
||||||
|
Ok(output) => output,
|
||||||
|
Err(_) => return None,
|
||||||
|
};
|
||||||
|
|
||||||
|
let version = match str::from_utf8(&output.stdout) {
|
||||||
|
Ok(version) => version,
|
||||||
|
Err(_) => return None,
|
||||||
|
};
|
||||||
|
|
||||||
let mut pieces = version.split('.');
|
let mut pieces = version.split('.');
|
||||||
if pieces.next() != Some("rustc 1") {
|
if pieces.next() != Some("rustc 1") {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
pieces.next()?.parse().ok()
|
|
||||||
|
let next = match pieces.next() {
|
||||||
|
Some(next) => next,
|
||||||
|
None => return None,
|
||||||
|
};
|
||||||
|
|
||||||
|
u32::from_str(next).ok()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user