summaryrefslogtreecommitdiffstats
path: root/vendor/serde/src/ser
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:50 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:50 +0000
commit2e00214b3efbdfeefaa0fe9e8b8fd519de7adc35 (patch)
treed325add32978dbdc1db975a438b3a77d571b1ab8 /vendor/serde/src/ser
parentReleasing progress-linux version 1.68.2+dfsg1-1~progress7.99u1. (diff)
downloadrustc-2e00214b3efbdfeefaa0fe9e8b8fd519de7adc35.tar.xz
rustc-2e00214b3efbdfeefaa0fe9e8b8fd519de7adc35.zip
Merging upstream version 1.69.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/serde/src/ser')
-rw-r--r--vendor/serde/src/ser/impls.rs70
-rw-r--r--vendor/serde/src/ser/mod.rs10
2 files changed, 64 insertions, 16 deletions
diff --git a/vendor/serde/src/ser/impls.rs b/vendor/serde/src/ser/impls.rs
index 8e8655582..da2677261 100644
--- a/vendor/serde/src/ser/impls.rs
+++ b/vendor/serde/src/ser/impls.rs
@@ -182,9 +182,27 @@ where
}
}
-#[cfg(any(feature = "std", feature = "alloc"))]
+#[cfg(all(any(feature = "std", feature = "alloc"), not(no_relaxed_trait_bounds)))]
macro_rules! seq_impl {
- ($ty:ident < T $(: $tbound1:ident $(+ $tbound2:ident)*)* $(, $typaram:ident : $bound:ident)* >) => {
+ ($ty:ident <T $(: $tbound1:ident $(+ $tbound2:ident)*)* $(, $typaram:ident : $bound:ident)*>) => {
+ impl<T $(, $typaram)*> Serialize for $ty<T $(, $typaram)*>
+ where
+ T: Serialize,
+ {
+ #[inline]
+ fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
+ where
+ S: Serializer,
+ {
+ serializer.collect_seq(self)
+ }
+ }
+ }
+}
+
+#[cfg(all(any(feature = "std", feature = "alloc"), no_relaxed_trait_bounds))]
+macro_rules! seq_impl {
+ ($ty:ident <T $(: $tbound1:ident $(+ $tbound2:ident)*)* $(, $typaram:ident : $bound:ident)*>) => {
impl<T $(, $typaram)*> Serialize for $ty<T $(, $typaram)*>
where
T: Serialize $(+ $tbound1 $(+ $tbound2)*)*,
@@ -347,9 +365,28 @@ tuple_impls! {
////////////////////////////////////////////////////////////////////////////////
-#[cfg(any(feature = "std", feature = "alloc"))]
+#[cfg(all(any(feature = "std", feature = "alloc"), not(no_relaxed_trait_bounds)))]
+macro_rules! map_impl {
+ ($ty:ident <K $(: $kbound1:ident $(+ $kbound2:ident)*)*, V $(, $typaram:ident : $bound:ident)*>) => {
+ impl<K, V $(, $typaram)*> Serialize for $ty<K, V $(, $typaram)*>
+ where
+ K: Serialize,
+ V: Serialize,
+ {
+ #[inline]
+ fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
+ where
+ S: Serializer,
+ {
+ serializer.collect_map(self)
+ }
+ }
+ }
+}
+
+#[cfg(all(any(feature = "std", feature = "alloc"), no_relaxed_trait_bounds))]
macro_rules! map_impl {
- ($ty:ident < K $(: $kbound1:ident $(+ $kbound2:ident)*)*, V $(, $typaram:ident : $bound:ident)* >) => {
+ ($ty:ident <K $(: $kbound1:ident $(+ $kbound2:ident)*)*, V $(, $typaram:ident : $bound:ident)*>) => {
impl<K, V $(, $typaram)*> Serialize for $ty<K, V $(, $typaram)*>
where
K: Serialize $(+ $kbound1 $(+ $kbound2)*)*,
@@ -465,7 +502,7 @@ where
////////////////////////////////////////////////////////////////////////////////
macro_rules! nonzero_integers {
- ( $( $T: ident, )+ ) => {
+ ($($T:ident,)+) => {
$(
#[cfg(not(no_num_nonzero))]
impl Serialize for num::$T {
@@ -736,8 +773,9 @@ impl Serialize for net::Ipv4Addr {
// Skip over delimiters that we initialized buf with
written += format_u8(*oct, &mut buf[written + 1..]) + 1;
}
- // We've only written ASCII bytes to the buffer, so it is valid UTF-8
- serializer.serialize_str(unsafe { str::from_utf8_unchecked(&buf[..written]) })
+ // Safety: We've only written ASCII bytes to the buffer, so it is valid UTF-8
+ let buf = unsafe { str::from_utf8_unchecked(&buf[..written]) };
+ serializer.serialize_str(buf)
} else {
self.octets().serialize(serializer)
}
@@ -909,8 +947,9 @@ where
#[cfg(all(feature = "std", not(no_std_atomic)))]
macro_rules! atomic_impl {
- ($($ty:ident)*) => {
+ ($($ty:ident $size:expr)*) => {
$(
+ #[cfg(any(no_target_has_atomic, target_has_atomic = $size))]
impl Serialize for $ty {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
@@ -926,12 +965,19 @@ macro_rules! atomic_impl {
#[cfg(all(feature = "std", not(no_std_atomic)))]
atomic_impl! {
- AtomicBool
- AtomicI8 AtomicI16 AtomicI32 AtomicIsize
- AtomicU8 AtomicU16 AtomicU32 AtomicUsize
+ AtomicBool "8"
+ AtomicI8 "8"
+ AtomicI16 "16"
+ AtomicI32 "32"
+ AtomicIsize "ptr"
+ AtomicU8 "8"
+ AtomicU16 "16"
+ AtomicU32 "32"
+ AtomicUsize "ptr"
}
#[cfg(all(feature = "std", not(no_std_atomic64)))]
atomic_impl! {
- AtomicI64 AtomicU64
+ AtomicI64 "64"
+ AtomicU64 "64"
}
diff --git a/vendor/serde/src/ser/mod.rs b/vendor/serde/src/ser/mod.rs
index 9a21363d6..5c45426e8 100644
--- a/vendor/serde/src/ser/mod.rs
+++ b/vendor/serde/src/ser/mod.rs
@@ -115,10 +115,13 @@ mod impossible;
pub use self::impossible::Impossible;
+#[cfg(all(feature = "unstable", not(feature = "std")))]
+#[doc(inline)]
+pub use core::error::Error as StdError;
#[cfg(feature = "std")]
#[doc(no_inline)]
pub use std::error::Error as StdError;
-#[cfg(not(feature = "std"))]
+#[cfg(not(any(feature = "std", feature = "unstable")))]
#[doc(no_inline)]
pub use std_error::Error as StdError;
@@ -191,8 +194,8 @@ declare_error_trait!(Error: Sized + Debug + Display);
/// by Serde.
///
/// Serde provides `Serialize` implementations for many Rust primitive and
-/// standard library types. The complete list is [here][ser]. All of these can
-/// be serialized using Serde out of the box.
+/// standard library types. The complete list is [here][crate::ser]. All of
+/// these can be serialized using Serde out of the box.
///
/// Additionally, Serde provides a procedural macro called [`serde_derive`] to
/// automatically generate `Serialize` implementations for structs and enums in
@@ -212,7 +215,6 @@ declare_error_trait!(Error: Sized + Debug + Display);
/// [`linked-hash-map`]: https://crates.io/crates/linked-hash-map
/// [`serde_derive`]: https://crates.io/crates/serde_derive
/// [derive section of the manual]: https://serde.rs/derive.html
-/// [ser]: https://docs.serde.rs/serde/ser/index.html
pub trait Serialize {
/// Serialize this value into the given Serde serializer.
///