Add build gate for nonzero signed integers so rustc <1.34 still works

This commit is contained in:
Flaise 2019-07-28 11:44:31 -05:00
parent 34866e20a8
commit 78c7f09e28
3 changed files with 18 additions and 1 deletions

View File

@ -69,11 +69,12 @@ fn main() {
println!("cargo:rustc-cfg=num_nonzero");
}
// TryFrom and Atomic types stabilized in Rust 1.34:
// TryFrom, Atomic types, and non-zero signed integers stabilized in Rust 1.34:
// https://blog.rust-lang.org/2019/04/11/Rust-1.34.0.html#tryfrom-and-tryinto
// https://blog.rust-lang.org/2019/04/11/Rust-1.34.0.html#library-stabilizations
if minor >= 34 {
println!("cargo:rustc-cfg=core_try_from");
println!("cargo:rustc-cfg=num_nonzero_signed");
// Whitelist of archs that support std::sync::atomic module. Ideally we
// would use #[cfg(target_has_atomic = "...")] but it is not stable yet.

View File

@ -2409,6 +2409,10 @@ nonzero_integers! {
NonZeroU32,
NonZeroU64,
NonZeroUsize,
}
#[cfg(num_nonzero_signed)]
nonzero_integers! {
NonZeroI8,
NonZeroI16,
NonZeroI32,
@ -2421,6 +2425,10 @@ nonzero_integers! {
serde_if_integer128! {
nonzero_integers! {
NonZeroU128,
}
#[cfg(num_nonzero_signed)]
nonzero_integers! {
NonZeroI128,
}
}

View File

@ -486,6 +486,10 @@ nonzero_integers! {
NonZeroU32,
NonZeroU64,
NonZeroUsize,
}
#[cfg(num_nonzero_signed)]
nonzero_integers! {
NonZeroI8,
NonZeroI16,
NonZeroI32,
@ -498,6 +502,10 @@ nonzero_integers! {
serde_if_integer128! {
nonzero_integers! {
NonZeroU128,
}
#[cfg(num_nonzero_signed)]
nonzero_integers! {
NonZeroI128,
}
}