-
-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #224 from mystor/rm_invalid_span_workaround
Disable the invalid span workaround in spanned.rs on patched versions of rustc
- Loading branch information
Showing
2 changed files
with
41 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
use std::env; | ||
use std::process::{self, Command}; | ||
use std::str; | ||
|
||
fn main() { | ||
println!("cargo:rerun-if-changed=build.rs"); | ||
|
||
let version = match rustc_version() { | ||
Some(version) => version, | ||
None => return, | ||
}; | ||
|
||
if version.minor < 31 { | ||
eprintln!("Minimum supported rustc version is 1.31"); | ||
process::exit(1); | ||
} | ||
|
||
if version.minor < 53 { | ||
println!("cargo:rustc-cfg=needs_invalid_span_workaround"); | ||
} | ||
} | ||
|
||
struct RustcVersion { | ||
minor: u32, | ||
} | ||
|
||
fn rustc_version() -> Option<RustcVersion> { | ||
let rustc = env::var_os("RUSTC")?; | ||
let output = Command::new(rustc).arg("--version").output().ok()?; | ||
let version = str::from_utf8(&output.stdout).ok()?; | ||
let mut pieces = version.split('.'); | ||
if pieces.next() != Some("rustc 1") { | ||
return None; | ||
} | ||
let minor = pieces.next()?.parse().ok()?; | ||
Some(RustcVersion { minor }) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters