diff --git a/serde/build.rs b/serde/build.rs index 61376081..ca991a5d 100644 --- a/serde/build.rs +++ b/serde/build.rs @@ -71,6 +71,11 @@ fn main() { println!("cargo:rustc-cfg=num_nonzero"); } + // Current minimum supported version of serde_derive crate is Rust 1.31. + if minor >= 31 { + println!("cargo:rustc-cfg=serde_derive"); + } + // 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 diff --git a/serde/src/private/mod.rs b/serde/src/private/mod.rs index 0bd5ca87..24ea84b3 100644 --- a/serde/src/private/mod.rs +++ b/serde/src/private/mod.rs @@ -1,5 +1,8 @@ +#[cfg(serde_derive)] pub mod de; +#[cfg(serde_derive)] pub mod ser; + pub mod size_hint; // FIXME: #[cfg(doctest)] once https://github.com/rust-lang/rust/issues/67295 is fixed.