diff --git a/serde/build.rs b/serde/build.rs index 391c5a2e..fcff8e6d 100644 --- a/serde/build.rs +++ b/serde/build.rs @@ -39,6 +39,13 @@ fn main() { println!("cargo:rustc-cfg=de_boxed_c_str"); } + // From> for Rc / Arc stabilized in Rust 1.21: + // https://doc.rust-lang.org/std/rc/struct.Rc.html#impl-From> + // https://doc.rust-lang.org/std/sync/struct.Arc.html#impl-From> + if minor >= 21 { + println!("cargo:rustc-cfg=de_rc_dst"); + } + // 128-bit integers stabilized in Rust 1.26: // https://blog.rust-lang.org/2018/05/10/Rust-1.26.html if minor >= 26 { diff --git a/serde/src/de/impls.rs b/serde/src/de/impls.rs index 6d325883..342ca3be 100644 --- a/serde/src/de/impls.rs +++ b/serde/src/de/impls.rs @@ -1528,7 +1528,7 @@ forwarded_impl!((T), Box<[T]>, Vec::into_boxed_slice); #[cfg(any(feature = "std", feature = "alloc"))] forwarded_impl!((), Box, String::into_boxed_str); -#[cfg(all(not(feature = "unstable"), feature = "rc", any(feature = "std", feature = "alloc")))] +#[cfg(all(not(de_rc_dst), feature = "rc", any(feature = "std", feature = "alloc")))] forwarded_impl! { /// This impl requires the [`"rc"`] Cargo feature of Serde. /// @@ -1540,7 +1540,7 @@ forwarded_impl! { (T), Arc, Arc::new } -#[cfg(all(not(feature = "unstable"), feature = "rc", any(feature = "std", feature = "alloc")))] +#[cfg(all(not(de_rc_dst), feature = "rc", any(feature = "std", feature = "alloc")))] forwarded_impl! { /// This impl requires the [`"rc"`] Cargo feature of Serde. /// @@ -1607,7 +1607,7 @@ where //////////////////////////////////////////////////////////////////////////////// -#[cfg(all(feature = "unstable", feature = "rc", any(feature = "std", feature = "alloc")))] +#[cfg(all(de_rc_dst, feature = "rc", any(feature = "std", feature = "alloc")))] macro_rules! box_forwarded_impl { ( $(#[doc = $doc:tt])* @@ -1628,7 +1628,7 @@ macro_rules! box_forwarded_impl { }; } -#[cfg(all(feature = "unstable", feature = "rc", any(feature = "std", feature = "alloc")))] +#[cfg(all(de_rc_dst, feature = "rc", any(feature = "std", feature = "alloc")))] box_forwarded_impl! { /// This impl requires the [`"rc"`] Cargo feature of Serde. /// @@ -1640,7 +1640,7 @@ box_forwarded_impl! { Rc } -#[cfg(all(feature = "unstable", feature = "rc", any(feature = "std", feature = "alloc")))] +#[cfg(all(de_rc_dst, feature = "rc", any(feature = "std", feature = "alloc")))] box_forwarded_impl! { /// This impl requires the [`"rc"`] Cargo feature of Serde. ///