mirror of
https://gitee.com/openharmony/third_party_rust_syn
synced 2024-11-23 16:00:10 +00:00
Disable nightly-only tests on non nightly compiler
This commit is contained in:
parent
d01c8935aa
commit
f83b6c9816
29
build.rs
29
build.rs
@ -6,22 +6,31 @@ use std::str::{self, FromStr};
|
||||
// opening a GitHub issue if your build environment requires some way to enable
|
||||
// these cfgs other than by executing our build script.
|
||||
fn main() {
|
||||
let minor = match rustc_minor_version() {
|
||||
Some(minor) => minor,
|
||||
let compiler = match rustc_version() {
|
||||
Some(compiler) => compiler,
|
||||
None => return,
|
||||
};
|
||||
|
||||
if minor >= 19 {
|
||||
if compiler.minor >= 19 {
|
||||
println!("cargo:rustc-cfg=syn_can_use_thread_id");
|
||||
}
|
||||
|
||||
// Macro modularization allows re-exporting the `quote!` macro in 1.30+.
|
||||
if minor >= 30 {
|
||||
if compiler.minor >= 30 {
|
||||
println!("cargo:rustc-cfg=syn_can_call_macro_by_path");
|
||||
}
|
||||
|
||||
if !compiler.nightly {
|
||||
println!("cargo:rustc-cfg=syn_disable_nightly_tests");
|
||||
}
|
||||
}
|
||||
|
||||
fn rustc_minor_version() -> Option<u32> {
|
||||
struct Compiler {
|
||||
minor: u32,
|
||||
nightly: bool,
|
||||
}
|
||||
|
||||
fn rustc_version() -> Option<Compiler> {
|
||||
let rustc = match env::var_os("RUSTC") {
|
||||
Some(rustc) => rustc,
|
||||
None => return None,
|
||||
@ -47,5 +56,13 @@ fn rustc_minor_version() -> Option<u32> {
|
||||
None => return None,
|
||||
};
|
||||
|
||||
u32::from_str(next).ok()
|
||||
let minor = match u32::from_str(next) {
|
||||
Ok(minor) => minor,
|
||||
Err(_) => return None,
|
||||
};
|
||||
|
||||
Some(Compiler {
|
||||
minor: minor,
|
||||
nightly: version.contains("nightly"),
|
||||
})
|
||||
}
|
||||
|
@ -1,3 +1,4 @@
|
||||
#![cfg(not(syn_disable_nightly_tests))]
|
||||
#![recursion_limit = "1024"]
|
||||
#![feature(rustc_private)]
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
#![cfg(not(syn_disable_nightly_tests))]
|
||||
#![recursion_limit = "1024"]
|
||||
#![feature(rustc_private)]
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
#![cfg(not(syn_disable_nightly_tests))]
|
||||
#![recursion_limit = "1024"]
|
||||
#![feature(rustc_private)]
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
#![cfg(not(syn_disable_nightly_tests))]
|
||||
#![recursion_limit = "1024"]
|
||||
#![feature(rustc_private)]
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user