diff --git a/serde/src/ser/impls.rs b/serde/src/ser/impls.rs index e0caf4c1..ea59b78d 100644 --- a/serde/src/ser/impls.rs +++ b/serde/src/ser/impls.rs @@ -340,10 +340,10 @@ deref_impl!(<'a, T: ?Sized> Serialize for &'a mut T where T: Serialize); deref_impl!( Serialize for Box where T: Serialize); #[cfg(all(feature = "rc", any(feature = "std", feature = "alloc")))] -deref_impl!( Serialize for Rc where T: Serialize); +deref_impl!( Serialize for Rc where T: Serialize); #[cfg(all(feature = "rc", any(feature = "std", feature = "alloc")))] -deref_impl!( Serialize for Arc where T: Serialize); +deref_impl!( Serialize for Arc where T: Serialize); #[cfg(any(feature = "std", feature = "alloc"))] deref_impl!(<'a, T: ?Sized> Serialize for Cow<'a, T> where T: Serialize + ToOwned); diff --git a/test_suite/Cargo.toml b/test_suite/Cargo.toml index bd0a5718..c859ed8d 100644 --- a/test_suite/Cargo.toml +++ b/test_suite/Cargo.toml @@ -10,7 +10,7 @@ unstable = ["serde/unstable", "compiletest_rs"] [dev-dependencies] fnv = "1.0" rustc-serialize = "0.3.16" -serde = { path = "../serde" } +serde = { path = "../serde", features = ["rc"] } serde_derive = { path = "../serde_derive" } serde_test = { path = "../serde_test" } diff --git a/test_suite/tests/test_ser.rs b/test_suite/tests/test_ser.rs index 9848cd69..9dfb7053 100644 --- a/test_suite/tests/test_ser.rs +++ b/test_suite/tests/test_ser.rs @@ -14,6 +14,8 @@ use std::net; use std::path::{Path, PathBuf}; use std::time::{Duration, UNIX_EPOCH}; use std::ffi::CString; +use std::rc::Rc; +use std::sync::Arc; #[cfg(unix)] use std::str; @@ -383,6 +385,41 @@ declare_tests! { Token::Bytes(b"abc"), ], } + test_rc { + Rc::new(true) => &[ + Token::Bool(true), + ], + } + test_arc { + Arc::new(true) => &[ + Token::Bool(true), + ], + } +} + +// Serde's implementation is not unstable, but the constructors are. +#[cfg(feature = "unstable")] +declare_tests! { + test_rc_dst { + Rc::::from("s") => &[ + Token::Str("s"), + ], + Rc::<[bool]>::from(&[true][..]) => &[ + Token::Seq { len: Some(1) }, + Token::Bool(true), + Token::SeqEnd, + ], + } + test_arc_dst { + Arc::::from("s") => &[ + Token::Str("s"), + ], + Arc::<[bool]>::from(&[true][..]) => &[ + Token::Seq { len: Some(1) }, + Token::Bool(true), + Token::SeqEnd, + ], + } } #[cfg(feature = "unstable")]