diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:43:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:43:14 +0000 |
commit | 8dd16259287f58f9273002717ec4d27e97127719 (patch) | |
tree | 3863e62a53829a84037444beab3abd4ed9dfc7d0 /third_party/rust/serde/src/private | |
parent | Releasing progress-linux version 126.0.1-1~progress7.99u1. (diff) | |
download | firefox-8dd16259287f58f9273002717ec4d27e97127719.tar.xz firefox-8dd16259287f58f9273002717ec4d27e97127719.zip |
Merging upstream version 127.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/rust/serde/src/private')
-rw-r--r-- | third_party/rust/serde/src/private/de.rs | 7 | ||||
-rw-r--r-- | third_party/rust/serde/src/private/doc.rs | 5 | ||||
-rw-r--r-- | third_party/rust/serde/src/private/ser.rs | 132 |
3 files changed, 67 insertions, 77 deletions
diff --git a/third_party/rust/serde/src/private/de.rs b/third_party/rust/serde/src/private/de.rs index 883e6909c1..c402d2c66a 100644 --- a/third_party/rust/serde/src/private/de.rs +++ b/third_party/rust/serde/src/private/de.rs @@ -313,6 +313,8 @@ mod content { } } + /// Used to capture data in [`Content`] from other deserializers. + /// Cannot capture externally tagged enums, `i128` and `u128`. struct ContentVisitor<'de> { value: PhantomData<Content<'de>>, } @@ -528,6 +530,8 @@ mod content { Content(Content<'de>), } + /// Serves as a seed for deserializing a key of internally tagged enum. + /// Cannot capture externally tagged enums, `i128` and `u128`. struct TagOrContentVisitor<'de> { name: &'static str, value: PhantomData<TagOrContent<'de>>, @@ -814,6 +818,9 @@ mod content { /// Used by generated code to deserialize an internally tagged enum. /// + /// Captures map or sequence from the original deserializer and searches + /// a tag in it (in case of sequence, tag is the first element of sequence). + /// /// Not public API. pub struct TaggedContentVisitor<T> { tag_name: &'static str, diff --git a/third_party/rust/serde/src/private/doc.rs b/third_party/rust/serde/src/private/doc.rs index 1b18fe6b41..1f17c8db53 100644 --- a/third_party/rust/serde/src/private/doc.rs +++ b/third_party/rust/serde/src/private/doc.rs @@ -56,7 +56,10 @@ macro_rules! __serialize_unimplemented { #[macro_export] macro_rules! __serialize_unimplemented_method { ($func:ident $(<$t:ident>)* ($($arg:ty),*) -> $ret:ident) => { - fn $func $(<$t: ?Sized + $crate::Serialize>)* (self $(, _: $arg)*) -> $crate::__private::Result<Self::$ret, Self::Error> { + fn $func $(<$t>)* (self $(, _: $arg)*) -> $crate::__private::Result<Self::$ret, Self::Error> + where + $($t: ?Sized + $crate::Serialize,)* + { unimplemented!() } }; diff --git a/third_party/rust/serde/src/private/ser.rs b/third_party/rust/serde/src/private/ser.rs index 50bcb251e3..40cc6cbdb7 100644 --- a/third_party/rust/serde/src/private/ser.rs +++ b/third_party/rust/serde/src/private/ser.rs @@ -174,9 +174,9 @@ where Err(self.bad_type(Unsupported::Optional)) } - fn serialize_some<T: ?Sized>(self, _: &T) -> Result<Self::Ok, Self::Error> + fn serialize_some<T>(self, _: &T) -> Result<Self::Ok, Self::Error> where - T: Serialize, + T: ?Sized + Serialize, { Err(self.bad_type(Unsupported::Optional)) } @@ -205,18 +205,18 @@ where map.end() } - fn serialize_newtype_struct<T: ?Sized>( + fn serialize_newtype_struct<T>( self, _: &'static str, value: &T, ) -> Result<Self::Ok, Self::Error> where - T: Serialize, + T: ?Sized + Serialize, { value.serialize(self) } - fn serialize_newtype_variant<T: ?Sized>( + fn serialize_newtype_variant<T>( self, _: &'static str, _: u32, @@ -224,7 +224,7 @@ where inner_value: &T, ) -> Result<Self::Ok, Self::Error> where - T: Serialize, + T: ?Sized + Serialize, { let mut map = tri!(self.delegate.serialize_map(Some(2))); tri!(map.serialize_entry(self.tag, self.variant_name)); @@ -327,9 +327,9 @@ where } #[cfg(not(any(feature = "std", feature = "alloc")))] - fn collect_str<T: ?Sized>(self, _: &T) -> Result<Self::Ok, Self::Error> + fn collect_str<T>(self, _: &T) -> Result<Self::Ok, Self::Error> where - T: Display, + T: ?Sized + Display, { Err(self.bad_type(Unsupported::String)) } @@ -364,9 +364,9 @@ mod content { type Ok = M::Ok; type Error = M::Error; - fn serialize_field<T: ?Sized>(&mut self, value: &T) -> Result<(), M::Error> + fn serialize_field<T>(&mut self, value: &T) -> Result<(), M::Error> where - T: Serialize, + T: ?Sized + Serialize, { let value = tri!(value.serialize(ContentSerializer::<M::Error>::new())); self.fields.push(value); @@ -404,13 +404,9 @@ mod content { type Ok = M::Ok; type Error = M::Error; - fn serialize_field<T: ?Sized>( - &mut self, - key: &'static str, - value: &T, - ) -> Result<(), M::Error> + fn serialize_field<T>(&mut self, key: &'static str, value: &T) -> Result<(), M::Error> where - T: Serialize, + T: ?Sized + Serialize, { let value = tri!(value.serialize(ContentSerializer::<M::Error>::new())); self.fields.push((key, value)); @@ -635,9 +631,9 @@ mod content { Ok(Content::None) } - fn serialize_some<T: ?Sized>(self, value: &T) -> Result<Content, E> + fn serialize_some<T>(self, value: &T) -> Result<Content, E> where - T: Serialize, + T: ?Sized + Serialize, { Ok(Content::Some(Box::new(tri!(value.serialize(self))))) } @@ -659,13 +655,9 @@ mod content { Ok(Content::UnitVariant(name, variant_index, variant)) } - fn serialize_newtype_struct<T: ?Sized>( - self, - name: &'static str, - value: &T, - ) -> Result<Content, E> + fn serialize_newtype_struct<T>(self, name: &'static str, value: &T) -> Result<Content, E> where - T: Serialize, + T: ?Sized + Serialize, { Ok(Content::NewtypeStruct( name, @@ -673,7 +665,7 @@ mod content { )) } - fn serialize_newtype_variant<T: ?Sized>( + fn serialize_newtype_variant<T>( self, name: &'static str, variant_index: u32, @@ -681,7 +673,7 @@ mod content { value: &T, ) -> Result<Content, E> where - T: Serialize, + T: ?Sized + Serialize, { Ok(Content::NewtypeVariant( name, @@ -782,9 +774,9 @@ mod content { type Ok = Content; type Error = E; - fn serialize_element<T: ?Sized>(&mut self, value: &T) -> Result<(), E> + fn serialize_element<T>(&mut self, value: &T) -> Result<(), E> where - T: Serialize, + T: ?Sized + Serialize, { let value = tri!(value.serialize(ContentSerializer::<E>::new())); self.elements.push(value); @@ -808,9 +800,9 @@ mod content { type Ok = Content; type Error = E; - fn serialize_element<T: ?Sized>(&mut self, value: &T) -> Result<(), E> + fn serialize_element<T>(&mut self, value: &T) -> Result<(), E> where - T: Serialize, + T: ?Sized + Serialize, { let value = tri!(value.serialize(ContentSerializer::<E>::new())); self.elements.push(value); @@ -835,9 +827,9 @@ mod content { type Ok = Content; type Error = E; - fn serialize_field<T: ?Sized>(&mut self, value: &T) -> Result<(), E> + fn serialize_field<T>(&mut self, value: &T) -> Result<(), E> where - T: Serialize, + T: ?Sized + Serialize, { let value = tri!(value.serialize(ContentSerializer::<E>::new())); self.fields.push(value); @@ -864,9 +856,9 @@ mod content { type Ok = Content; type Error = E; - fn serialize_field<T: ?Sized>(&mut self, value: &T) -> Result<(), E> + fn serialize_field<T>(&mut self, value: &T) -> Result<(), E> where - T: Serialize, + T: ?Sized + Serialize, { let value = tri!(value.serialize(ContentSerializer::<E>::new())); self.fields.push(value); @@ -896,18 +888,18 @@ mod content { type Ok = Content; type Error = E; - fn serialize_key<T: ?Sized>(&mut self, key: &T) -> Result<(), E> + fn serialize_key<T>(&mut self, key: &T) -> Result<(), E> where - T: Serialize, + T: ?Sized + Serialize, { let key = tri!(key.serialize(ContentSerializer::<E>::new())); self.key = Some(key); Ok(()) } - fn serialize_value<T: ?Sized>(&mut self, value: &T) -> Result<(), E> + fn serialize_value<T>(&mut self, value: &T) -> Result<(), E> where - T: Serialize, + T: ?Sized + Serialize, { let key = self .key @@ -922,10 +914,10 @@ mod content { Ok(Content::Map(self.entries)) } - fn serialize_entry<K: ?Sized, V: ?Sized>(&mut self, key: &K, value: &V) -> Result<(), E> + fn serialize_entry<K, V>(&mut self, key: &K, value: &V) -> Result<(), E> where - K: Serialize, - V: Serialize, + K: ?Sized + Serialize, + V: ?Sized + Serialize, { let key = tri!(key.serialize(ContentSerializer::<E>::new())); let value = tri!(value.serialize(ContentSerializer::<E>::new())); @@ -947,9 +939,9 @@ mod content { type Ok = Content; type Error = E; - fn serialize_field<T: ?Sized>(&mut self, key: &'static str, value: &T) -> Result<(), E> + fn serialize_field<T>(&mut self, key: &'static str, value: &T) -> Result<(), E> where - T: Serialize, + T: ?Sized + Serialize, { let value = tri!(value.serialize(ContentSerializer::<E>::new())); self.fields.push((key, value)); @@ -976,9 +968,9 @@ mod content { type Ok = Content; type Error = E; - fn serialize_field<T: ?Sized>(&mut self, key: &'static str, value: &T) -> Result<(), E> + fn serialize_field<T>(&mut self, key: &'static str, value: &T) -> Result<(), E> where - T: Serialize, + T: ?Sized + Serialize, { let value = tri!(value.serialize(ContentSerializer::<E>::new())); self.fields.push((key, value)); @@ -1088,9 +1080,9 @@ where Ok(()) } - fn serialize_some<T: ?Sized>(self, value: &T) -> Result<Self::Ok, Self::Error> + fn serialize_some<T>(self, value: &T) -> Result<Self::Ok, Self::Error> where - T: Serialize, + T: ?Sized + Serialize, { value.serialize(self) } @@ -1112,18 +1104,18 @@ where Err(Self::bad_type(Unsupported::Enum)) } - fn serialize_newtype_struct<T: ?Sized>( + fn serialize_newtype_struct<T>( self, _: &'static str, value: &T, ) -> Result<Self::Ok, Self::Error> where - T: Serialize, + T: ?Sized + Serialize, { value.serialize(self) } - fn serialize_newtype_variant<T: ?Sized>( + fn serialize_newtype_variant<T>( self, _: &'static str, _: u32, @@ -1131,7 +1123,7 @@ where value: &T, ) -> Result<Self::Ok, Self::Error> where - T: Serialize, + T: ?Sized + Serialize, { tri!(self.0.serialize_key(variant)); self.0.serialize_value(value) @@ -1202,28 +1194,24 @@ where type Ok = (); type Error = M::Error; - fn serialize_key<T: ?Sized>(&mut self, key: &T) -> Result<(), Self::Error> + fn serialize_key<T>(&mut self, key: &T) -> Result<(), Self::Error> where - T: Serialize, + T: ?Sized + Serialize, { self.0.serialize_key(key) } - fn serialize_value<T: ?Sized>(&mut self, value: &T) -> Result<(), Self::Error> + fn serialize_value<T>(&mut self, value: &T) -> Result<(), Self::Error> where - T: Serialize, + T: ?Sized + Serialize, { self.0.serialize_value(value) } - fn serialize_entry<K: ?Sized, V: ?Sized>( - &mut self, - key: &K, - value: &V, - ) -> Result<(), Self::Error> + fn serialize_entry<K, V>(&mut self, key: &K, value: &V) -> Result<(), Self::Error> where - K: Serialize, - V: Serialize, + K: ?Sized + Serialize, + V: ?Sized + Serialize, { self.0.serialize_entry(key, value) } @@ -1244,13 +1232,9 @@ where type Ok = (); type Error = M::Error; - fn serialize_field<T: ?Sized>( - &mut self, - key: &'static str, - value: &T, - ) -> Result<(), Self::Error> + fn serialize_field<T>(&mut self, key: &'static str, value: &T) -> Result<(), Self::Error> where - T: Serialize, + T: ?Sized + Serialize, { self.0.serialize_entry(key, value) } @@ -1289,9 +1273,9 @@ where type Ok = (); type Error = M::Error; - fn serialize_field<T: ?Sized>(&mut self, value: &T) -> Result<(), Self::Error> + fn serialize_field<T>(&mut self, value: &T) -> Result<(), Self::Error> where - T: Serialize, + T: ?Sized + Serialize, { let value = tri!(value.serialize(ContentSerializer::<M::Error>::new())); self.fields.push(value); @@ -1335,13 +1319,9 @@ where type Ok = (); type Error = M::Error; - fn serialize_field<T: ?Sized>( - &mut self, - key: &'static str, - value: &T, - ) -> Result<(), Self::Error> + fn serialize_field<T>(&mut self, key: &'static str, value: &T) -> Result<(), Self::Error> where - T: Serialize, + T: ?Sized + Serialize, { let value = tri!(value.serialize(ContentSerializer::<M::Error>::new())); self.fields.push((key, value)); |