Skip to content

Commit

Permalink
Merge pull request #1285 from dtolnay/rcdst
Browse files Browse the repository at this point in the history
Stabilize impls for dynamically sized Rc / Arc
  • Loading branch information
dtolnay committed May 26, 2018
2 parents 8a59695 + 320a059 commit 99091d5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
7 changes: 7 additions & 0 deletions serde/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ fn main() {
println!("cargo:rustc-cfg=de_boxed_c_str");
}

// From<Box<T>> for Rc<T> / Arc<T> stabilized in Rust 1.21:
// https://doc.rust-lang.org/std/rc/struct.Rc.html#impl-From<Box<T>>
// https://doc.rust-lang.org/std/sync/struct.Arc.html#impl-From<Box<T>>
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 {
Expand Down
10 changes: 5 additions & 5 deletions serde/src/de/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1528,7 +1528,7 @@ forwarded_impl!((T), Box<[T]>, Vec::into_boxed_slice);
#[cfg(any(feature = "std", feature = "alloc"))]
forwarded_impl!((), Box<str>, 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.
///
Expand All @@ -1540,7 +1540,7 @@ forwarded_impl! {
(T), Arc<T>, 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.
///
Expand Down Expand Up @@ -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])*
Expand All @@ -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.
///
Expand All @@ -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.
///
Expand Down

0 comments on commit 99091d5

Please sign in to comment.