diff --git a/serde/build.rs b/serde/build.rs index c9fdaf54..2d985b1c 100644 --- a/serde/build.rs +++ b/serde/build.rs @@ -69,7 +69,12 @@ fn main() { println!("cargo:rustc-cfg=num_nonzero"); } + // TryFrom and Atomic types 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"); + // Whitelist of archs that support std::sync::atomic module. Ideally we // would use #[cfg(target_has_atomic = "...")] but it is not stable yet. // Instead this is based on rustc's src/librustc_target/spec/*.rs. diff --git a/serde/src/export.rs b/serde/src/export.rs index 78c21e49..caa1f4dc 100644 --- a/serde/src/export.rs +++ b/serde/src/export.rs @@ -1,5 +1,5 @@ pub use lib::clone::Clone; -pub use lib::convert::{From, Into, TryFrom}; +pub use lib::convert::{From, Into}; pub use lib::default::Default; pub use lib::fmt::{self, Formatter}; pub use lib::marker::PhantomData; @@ -11,6 +11,9 @@ pub use self::string::from_utf8_lossy; #[cfg(any(feature = "alloc", feature = "std"))] pub use lib::{ToString, Vec}; +#[cfg(core_try_from)] +pub use lib::convert::TryFrom; + mod string { use lib::*;