summaryrefslogtreecommitdiffstats
path: root/vendor/serde/src
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/serde/src')
-rw-r--r--vendor/serde/src/de/format.rs4
-rw-r--r--vendor/serde/src/de/ignored_any.rs30
-rw-r--r--vendor/serde/src/de/impls.rs286
-rw-r--r--vendor/serde/src/de/mod.rs133
-rw-r--r--vendor/serde/src/de/seed.rs2
-rw-r--r--vendor/serde/src/de/size_hint.rs (renamed from vendor/serde/src/private/size_hint.rs)2
-rw-r--r--vendor/serde/src/de/utf8.rs46
-rw-r--r--vendor/serde/src/de/value.rs40
-rw-r--r--vendor/serde/src/integer128.rs79
-rw-r--r--vendor/serde/src/lib.rs124
-rw-r--r--vendor/serde/src/macros.rs8
-rw-r--r--vendor/serde/src/private/de.rs286
-rw-r--r--vendor/serde/src/private/doc.rs4
-rw-r--r--vendor/serde/src/private/mod.rs24
-rw-r--r--vendor/serde/src/private/ser.rs207
-rw-r--r--vendor/serde/src/ser/fmt.rs13
-rw-r--r--vendor/serde/src/ser/impls.rs73
-rw-r--r--vendor/serde/src/ser/impossible.rs4
-rw-r--r--vendor/serde/src/ser/mod.rs140
-rw-r--r--vendor/serde/src/std_error.rs2
20 files changed, 620 insertions, 887 deletions
diff --git a/vendor/serde/src/de/format.rs b/vendor/serde/src/de/format.rs
index f14580b8d..9053cc070 100644
--- a/vendor/serde/src/de/format.rs
+++ b/vendor/serde/src/de/format.rs
@@ -1,5 +1,5 @@
-use lib::fmt::{self, Write};
-use lib::str;
+use crate::lib::fmt::{self, Write};
+use crate::lib::str;
pub(super) struct Buf<'a> {
bytes: &'a mut [u8],
diff --git a/vendor/serde/src/de/ignored_any.rs b/vendor/serde/src/de/ignored_any.rs
index 01555a29f..2360a1742 100644
--- a/vendor/serde/src/de/ignored_any.rs
+++ b/vendor/serde/src/de/ignored_any.rs
@@ -1,6 +1,6 @@
-use lib::*;
+use crate::lib::*;
-use de::{
+use crate::de::{
Deserialize, Deserializer, EnumAccess, Error, MapAccess, SeqAccess, VariantAccess, Visitor,
};
@@ -129,12 +129,10 @@ impl<'de> Visitor<'de> for IgnoredAny {
Ok(IgnoredAny)
}
- serde_if_integer128! {
- #[inline]
- fn visit_i128<E>(self, x: i128) -> Result<Self::Value, E> {
- let _ = x;
- Ok(IgnoredAny)
- }
+ #[inline]
+ fn visit_i128<E>(self, x: i128) -> Result<Self::Value, E> {
+ let _ = x;
+ Ok(IgnoredAny)
}
#[inline]
@@ -143,12 +141,10 @@ impl<'de> Visitor<'de> for IgnoredAny {
Ok(IgnoredAny)
}
- serde_if_integer128! {
- #[inline]
- fn visit_u128<E>(self, x: u128) -> Result<Self::Value, E> {
- let _ = x;
- Ok(IgnoredAny)
- }
+ #[inline]
+ fn visit_u128<E>(self, x: u128) -> Result<Self::Value, E> {
+ let _ = x;
+ Ok(IgnoredAny)
}
#[inline]
@@ -197,7 +193,7 @@ impl<'de> Visitor<'de> for IgnoredAny {
where
A: SeqAccess<'de>,
{
- while let Some(IgnoredAny) = try!(seq.next_element()) {
+ while let Some(IgnoredAny) = tri!(seq.next_element()) {
// Gobble
}
Ok(IgnoredAny)
@@ -208,7 +204,7 @@ impl<'de> Visitor<'de> for IgnoredAny {
where
A: MapAccess<'de>,
{
- while let Some((IgnoredAny, IgnoredAny)) = try!(map.next_entry()) {
+ while let Some((IgnoredAny, IgnoredAny)) = tri!(map.next_entry()) {
// Gobble
}
Ok(IgnoredAny)
@@ -227,7 +223,7 @@ impl<'de> Visitor<'de> for IgnoredAny {
where
A: EnumAccess<'de>,
{
- try!(data.variant::<IgnoredAny>()).1.newtype_variant()
+ tri!(data.variant::<IgnoredAny>()).1.newtype_variant()
}
}
diff --git a/vendor/serde/src/de/impls.rs b/vendor/serde/src/de/impls.rs
index 12fbdfdb3..fbee1554b 100644
--- a/vendor/serde/src/de/impls.rs
+++ b/vendor/serde/src/de/impls.rs
@@ -1,16 +1,14 @@
-use lib::*;
+use crate::lib::*;
-use de::{
- Deserialize, Deserializer, EnumAccess, Error, SeqAccess, Unexpected, VariantAccess, Visitor,
+use crate::de::{
+ Deserialize, Deserializer, EnumAccess, Error, MapAccess, SeqAccess, Unexpected, VariantAccess,
+ Visitor,
};
-#[cfg(any(feature = "std", feature = "alloc", not(no_core_duration)))]
-use de::MapAccess;
-
-use seed::InPlaceSeed;
+use crate::seed::InPlaceSeed;
#[cfg(any(feature = "std", feature = "alloc"))]
-use __private::size_hint;
+use crate::de::size_hint;
////////////////////////////////////////////////////////////////////////////////
@@ -84,7 +82,7 @@ macro_rules! impl_deserialize_num {
($primitive:ident, $nonzero:ident $(cfg($($cfg:tt)*))*, $deserialize:ident $($method:ident!($($val:ident : $visit:ident)*);)*) => {
impl_deserialize_num!($primitive, $deserialize $($method!($($val : $visit)*);)*);
- #[cfg(all(not(no_num_nonzero), $($($cfg)*)*))]
+ $(#[cfg($($cfg)*)])*
impl<'de> Deserialize<'de> for num::$nonzero {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
@@ -366,64 +364,62 @@ impl_deserialize_num! {
num_as_self!(u8:visit_u8 u16:visit_u16 u32:visit_u32 u64:visit_u64);
}
-serde_if_integer128! {
- macro_rules! num_128 {
- ($ty:ident : $visit:ident) => {
- fn $visit<E>(self, v: $ty) -> Result<Self::Value, E>
- where
- E: Error,
+macro_rules! num_128 {
+ ($ty:ident : $visit:ident) => {
+ fn $visit<E>(self, v: $ty) -> Result<Self::Value, E>
+ where
+ E: Error,
+ {
+ if v as i128 >= Self::Value::min_value() as i128
+ && v as u128 <= Self::Value::max_value() as u128
{
- if v as i128 >= Self::Value::min_value() as i128
- && v as u128 <= Self::Value::max_value() as u128
- {
- Ok(v as Self::Value)
- } else {
- Err(Error::invalid_value(
- Unexpected::Other(stringify!($ty)),
- &self,
- ))
- }
+ Ok(v as Self::Value)
+ } else {
+ Err(Error::invalid_value(
+ Unexpected::Other(stringify!($ty)),
+ &self,
+ ))
}
- };
+ }
+ };
- (nonzero $primitive:ident $ty:ident : $visit:ident) => {
- fn $visit<E>(self, v: $ty) -> Result<Self::Value, E>
- where
- E: Error,
+ (nonzero $primitive:ident $ty:ident : $visit:ident) => {
+ fn $visit<E>(self, v: $ty) -> Result<Self::Value, E>
+ where
+ E: Error,
+ {
+ if v as i128 >= $primitive::min_value() as i128
+ && v as u128 <= $primitive::max_value() as u128
{
- if v as i128 >= $primitive::min_value() as i128
- && v as u128 <= $primitive::max_value() as u128
- {
- if let Some(nonzero) = Self::Value::new(v as $primitive) {
- Ok(nonzero)
- } else {
- Err(Error::invalid_value(Unexpected::Unsigned(0), &self))
- }
+ if let Some(nonzero) = Self::Value::new(v as $primitive) {
+ Ok(nonzero)
} else {
- Err(Error::invalid_value(
- Unexpected::Other(stringify!($ty)),
- &self,
- ))
+ Err(Error::invalid_value(Unexpected::Unsigned(0), &self))
}
+ } else {
+ Err(Error::invalid_value(
+ Unexpected::Other(stringify!($ty)),
+ &self,
+ ))
}
- };
- }
+ }
+ };
+}
- impl_deserialize_num! {
- i128, NonZeroI128 cfg(not(no_num_nonzero_signed)), deserialize_i128
- num_self!(i128:visit_i128);
- num_as_self!(i8:visit_i8 i16:visit_i16 i32:visit_i32 i64:visit_i64);
- num_as_self!(u8:visit_u8 u16:visit_u16 u32:visit_u32 u64:visit_u64);
- num_128!(u128:visit_u128);
- }
+impl_deserialize_num! {
+ i128, NonZeroI128 cfg(not(no_num_nonzero_signed)), deserialize_i128
+ num_self!(i128:visit_i128);
+ num_as_self!(i8:visit_i8 i16:visit_i16 i32:visit_i32 i64:visit_i64);
+ num_as_self!(u8:visit_u8 u16:visit_u16 u32:visit_u32 u64:visit_u64);
+ num_128!(u128:visit_u128);
+}
- impl_deserialize_num! {
- u128, NonZeroU128, deserialize_u128
- num_self!(u128:visit_u128);
- num_as_self!(u8:visit_u8 u16:visit_u16 u32:visit_u32 u64:visit_u64);
- int_to_uint!(i8:visit_i8 i16:visit_i16 i32:visit_i32 i64:visit_i64);
- num_128!(i128:visit_i128);
- }
+impl_deserialize_num! {
+ u128, NonZeroU128, deserialize_u128
+ num_self!(u128:visit_u128);
+ num_as_self!(u8:visit_u8 u16:visit_u16 u32:visit_u32 u64:visit_u64);
+ int_to_uint!(i8:visit_i8 i16:visit_i16 i32:visit_i32 i64:visit_i64);
+ num_128!(i128:visit_i128);
}
////////////////////////////////////////////////////////////////////////////////
@@ -684,7 +680,7 @@ impl<'de> Visitor<'de> for CStringVisitor {
let capacity = size_hint::cautious::<u8>(seq.size_hint());
let mut values = Vec::<u8>::with_capacity(capacity);
- while let Some(value) = try!(seq.next_element()) {
+ while let Some(value) = tri!(seq.next_element()) {
values.push(value);
}
@@ -747,13 +743,9 @@ macro_rules! forwarded_impl {
}
}
-#[cfg(all(
- any(feature = "std", all(not(no_core_cstr), feature = "alloc")),
- not(no_de_boxed_c_str)
-))]
+#[cfg(any(feature = "std", all(not(no_core_cstr), feature = "alloc")))]
forwarded_impl!((), Box<CStr>, CString::into_boxed_c_str);
-#[cfg(not(no_core_reverse))]
forwarded_impl!((T), Reverse<T>, Reverse);
////////////////////////////////////////////////////////////////////////////////
@@ -901,7 +893,7 @@ macro_rules! seq_impl {
{
let mut values = $with_capacity;
- while let Some(value) = try!($access.next_element()) {
+ while let Some(value) = tri!($access.next_element()) {
$insert(&mut values, value);
}
@@ -939,7 +931,7 @@ macro_rules! seq_impl {
$reserve(&mut self.0, size_hint::cautious::<T>($access.size_hint()));
// FIXME: try to overwrite old values here? (Vec, VecDeque, LinkedList)
- while let Some(value) = try!($access.next_element()) {
+ while let Some(value) = tri!($access.next_element()) {
$insert(&mut self.0, value);
}
@@ -1039,7 +1031,7 @@ where
let capacity = size_hint::cautious::<T>(seq.size_hint());
let mut values = Vec::<T>::with_capacity(capacity);
- while let Some(value) = try!(seq.next_element()) {
+ while let Some(value) = tri!(seq.next_element()) {
values.push(value);
}
@@ -1081,7 +1073,7 @@ where
for i in 0..self.0.len() {
let next = {
let next_place = InPlaceSeed(&mut self.0[i]);
- try!(seq.next_element_seed(next_place))
+ tri!(seq.next_element_seed(next_place))
};
if next.is_none() {
self.0.truncate(i);
@@ -1089,7 +1081,7 @@ where
}
}
- while let Some(value) = try!(seq.next_element()) {
+ while let Some(value) = tri!(seq.next_element()) {
self.0.push(value);
}
@@ -1161,7 +1153,7 @@ macro_rules! array_impls {
A: SeqAccess<'de>,
{
Ok([$(
- match try!(seq.next_element()) {
+ match tri!(seq.next_element()) {
Some(val) => val,
None => return Err(Error::invalid_length($n, &self)),
}
@@ -1186,7 +1178,7 @@ macro_rules! array_impls {
{
let mut fail_idx = None;
for (idx, dest) in self.0[..].iter_mut().enumerate() {
- if try!(seq.next_element_seed(InPlaceSeed(dest))).is_none() {
+ if tri!(seq.next_element_seed(InPlaceSeed(dest))).is_none() {
fail_idx = Some(idx);
break;
}
@@ -1284,7 +1276,7 @@ macro_rules! tuple_impls {
A: SeqAccess<'de>,
{
$(
- let $name = match try!(seq.next_element()) {
+ let $name = match tri!(seq.next_element()) {
Some(value) => value,
None => return Err(Error::invalid_length($n, &self)),
};
@@ -1318,7 +1310,7 @@ macro_rules! tuple_impls {
A: SeqAccess<'de>,
{
$(
- if try!(seq.next_element_seed(InPlaceSeed(&mut (self.0).$n))).is_none() {
+ if tri!(seq.next_element_seed(InPlaceSeed(&mut (self.0).$n))).is_none() {
return Err(Error::invalid_length($n, &self));
}
)+
@@ -1395,7 +1387,7 @@ macro_rules! map_impl {
{
let mut values = $with_capacity;
- while let Some((key, value)) = try!($access.next_entry()) {
+ while let Some((key, value)) = tri!($access.next_entry()) {
values.insert(key, value);
}
@@ -1541,7 +1533,7 @@ macro_rules! deserialize_enum {
where
A: EnumAccess<'de>,
{
- match try!(data.variant()) {
+ match tri!(data.variant()) {
$(
($name_kind :: $variant, v) => v.newtype_variant().map($name :: $variant),
)*
@@ -1561,7 +1553,7 @@ impl<'de> Deserialize<'de> for net::IpAddr {
if deserializer.is_human_readable() {
deserializer.deserialize_str(FromStrVisitor::new("IP address"))
} else {
- use lib::net::IpAddr;
+ use crate::lib::net::IpAddr;
deserialize_enum! {
IpAddr IpAddrKind (V4; b"V4"; 0, V6; b"V6"; 1)
"`V4` or `V6`",
@@ -1604,7 +1596,7 @@ impl<'de> Deserialize<'de> for net::SocketAddr {
if deserializer.is_human_readable() {
deserializer.deserialize_str(FromStrVisitor::new("socket address"))
} else {
- use lib::net::SocketAddr;
+ use crate::lib::net::SocketAddr;
deserialize_enum! {
SocketAddr SocketAddrKind (V4; b"V4"; 0, V6; b"V6"; 1)
"`V4` or `V6`",
@@ -1714,7 +1706,7 @@ impl<'de> Deserialize<'de> for PathBuf {
}
}
-#[cfg(all(feature = "std", not(no_de_boxed_path)))]
+#[cfg(feature = "std")]
forwarded_impl!((), Box<Path>, PathBuf::into_boxed_path);
////////////////////////////////////////////////////////////////////////////////
@@ -1748,7 +1740,7 @@ impl<'de> Visitor<'de> for OsStringVisitor {
{
use std::os::unix::ffi::OsStringExt;
- match try!(data.variant()) {
+ match tri!(data.variant()) {
(OsStringKind::Unix, v) => v.newtype_variant().map(OsString::from_vec),
(OsStringKind::Windows, _) => Err(Error::custom(
"cannot deserialize Windows OS string on Unix",
@@ -1763,7 +1755,7 @@ impl<'de> Visitor<'de> for OsStringVisitor {
{
use std::os::windows::ffi::OsStringExt;
- match try!(data.variant()) {
+ match tri!(data.variant()) {
(OsStringKind::Windows, v) => v
.newtype_variant::<Vec<u16>>()
.map(|vec| OsString::from_wide(&vec)),
@@ -1795,29 +1787,8 @@ 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(no_de_rc_dst, feature = "rc", any(feature = "std", feature = "alloc")))]
-forwarded_impl! {
- /// This impl requires the [`"rc"`] Cargo feature of Serde.
- ///
- /// Deserializing a data structure containing `Arc` will not attempt to
- /// deduplicate `Arc` references to the same data. Every deserialized `Arc`
- /// will end up with a strong count of 1.
- ///
- /// [`"rc"`]: https://serde.rs/feature-flags.html#-features-rc
- (T), Arc<T>, Arc::new
-}
-
-#[cfg(all(no_de_rc_dst, feature = "rc", any(feature = "std", feature = "alloc")))]
-forwarded_impl! {
- /// This impl requires the [`"rc"`] Cargo feature of Serde.
- ///
- /// Deserializing a data structure containing `Rc` will not attempt to
- /// deduplicate `Rc` references to the same data. Every deserialized `Rc`
- /// will end up with a strong count of 1.
- ///
- /// [`"rc"`]: https://serde.rs/feature-flags.html#-features-rc
- (T), Rc<T>, Rc::new
-}
+#[cfg(all(feature = "std", any(unix, windows)))]
+forwarded_impl!((), Box<OsStr>, OsString::into_boxed_os_str);
#[cfg(any(feature = "std", feature = "alloc"))]
impl<'de, 'a, T: ?Sized> Deserialize<'de> for Cow<'a, T>
@@ -1849,7 +1820,7 @@ where
where
D: Deserializer<'de>,
{
- try!(Option::<T>::deserialize(deserializer));
+ tri!(Option::<T>::deserialize(deserializer));
Ok(RcWeak::new())
}
}
@@ -1867,18 +1838,14 @@ where
where
D: Deserializer<'de>,
{
- try!(Option::<T>::deserialize(deserializer));
+ tri!(Option::<T>::deserialize(deserializer));
Ok(ArcWeak::new())
}
}
////////////////////////////////////////////////////////////////////////////////
-#[cfg(all(
- not(no_de_rc_dst),
- feature = "rc",
- any(feature = "std", feature = "alloc")
-))]
+#[cfg(all(feature = "rc", any(feature = "std", feature = "alloc")))]
macro_rules! box_forwarded_impl {
(
$(#[doc = $doc:tt])*
@@ -1899,11 +1866,7 @@ macro_rules! box_forwarded_impl {
};
}
-#[cfg(all(
- not(no_de_rc_dst),
- feature = "rc",
- any(feature = "std", feature = "alloc")
-))]
+#[cfg(all(feature = "rc", any(feature = "std", feature = "alloc")))]
box_forwarded_impl! {
/// This impl requires the [`"rc"`] Cargo feature of Serde.
///
@@ -1915,11 +1878,7 @@ box_forwarded_impl! {
Rc
}
-#[cfg(all(
- not(no_de_rc_dst),
- feature = "rc",
- any(feature = "std", feature = "alloc")
-))]
+#[cfg(all(feature = "rc", any(feature = "std", feature = "alloc")))]
box_forwarded_impl! {
/// This impl requires the [`"rc"`] Cargo feature of Serde.
///
@@ -1963,7 +1922,6 @@ forwarded_impl!((T), RwLock<T>, RwLock::new);
// secs: u64,
// nanos: u32,
// }
-#[cfg(any(feature = "std", not(no_core_duration)))]
impl<'de> Deserialize<'de> for Duration {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
@@ -2011,7 +1969,7 @@ impl<'de> Deserialize<'de> for Duration {
b"secs" => Ok(Field::Secs),
b"nanos" => Ok(Field::Nanos),
_ => {
- let value = ::__private::from_utf8_lossy(value);
+ let value = crate::__private::from_utf8_lossy(value);
Err(Error::unknown_field(&*value, FIELDS))
}
}
@@ -2046,19 +2004,19 @@ impl<'de> Deserialize<'de> for Duration {
where
A: SeqAccess<'de>,
{
- let secs: u64 = match try!(seq.next_element()) {
+ let secs: u64 = match tri!(seq.next_element()) {
Some(value) => value,
None => {
return Err(Error::invalid_length(0, &self));
}
};
- let nanos: u32 = match try!(seq.next_element()) {
+ let nanos: u32 = match tri!(seq.next_element()) {
Some(value) => value,
None => {
return Err(Error::invalid_length(1, &self));
}
};
- try!(check_overflow(secs, nanos));
+ tri!(check_overflow(secs, nanos));
Ok(Duration::new(secs, nanos))
}
@@ -2068,19 +2026,19 @@ impl<'de> Deserialize<'de> for Duration {
{
let mut secs: Option<u64> = None;
let mut nanos: Option<u32> = None;
- while let Some(key) = try!(map.next_key()) {
+ while let Some(key) = tri!(map.next_key()) {
match key {
Field::Secs => {
if secs.is_some() {
return Err(<A::Error as Error>::duplicate_field("secs"));
}
- secs = Some(try!(map.next_value()));
+ secs = Some(tri!(map.next_value()));
}
Field::Nanos => {
if nanos.is_some() {
return Err(<A::Error as Error>::duplicate_field("nanos"));
}
- nanos = Some(try!(map.next_value()));
+ nanos = Some(tri!(map.next_value()));
}
}
}
@@ -2092,7 +2050,7 @@ impl<'de> Deserialize<'de> for Duration {
Some(nanos) => nanos,
None => return Err(<A::Error as Error>::missing_field("nanos")),
};
- try!(check_overflow(secs, nanos));
+ tri!(check_overflow(secs, nanos));
Ok(Duration::new(secs, nanos))
}
}
@@ -2184,19 +2142,19 @@ impl<'de> Deserialize<'de> for SystemTime {
where
A: SeqAccess<'de>,
{
- let secs: u64 = match try!(seq.next_element()) {
+ let secs: u64 = match tri!(seq.next_element()) {
Some(value) => value,
None => {
return Err(Error::invalid_length(0, &self));
}
};
- let nanos: u32 = match try!(seq.next_element()) {
+ let nanos: u32 = match tri!(seq.next_element()) {
Some(value) => value,
None => {
return Err(Error::invalid_length(1, &self));
}
};
- try!(check_overflow(secs, nanos));
+ tri!(check_overflow(secs, nanos));
Ok(Duration::new(secs, nanos))
}
@@ -2206,7 +2164,7 @@ impl<'de> Deserialize<'de> for SystemTime {
{
let mut secs: Option<u64> = None;
let mut nanos: Option<u32> = None;
- while let Some(key) = try!(map.next_key()) {
+ while let Some(key) = tri!(map.next_key()) {
match key {
Field::Secs => {
if secs.is_some() {
@@ -2214,7 +2172,7 @@ impl<'de> Deserialize<'de> for SystemTime {
"secs_since_epoch",
));
}
- secs = Some(try!(map.next_value()));
+ secs = Some(tri!(map.next_value()));
}
Field::Nanos => {
if nanos.is_some() {
@@ -2222,7 +2180,7 @@ impl<'de> Deserialize<'de> for SystemTime {
"nanos_since_epoch",
));
}
- nanos = Some(try!(map.next_value()));
+ nanos = Some(tri!(map.next_value()));
}
}
}
@@ -2234,13 +2192,13 @@ impl<'de> Deserialize<'de> for SystemTime {
Some(nanos) => nanos,
None => return Err(<A::Error as Error>::missing_field("nanos_since_epoch")),
};
- try!(check_overflow(secs, nanos));
+ tri!(check_overflow(secs, nanos));
Ok(Duration::new(secs, nanos))
}
}
const FIELDS: &[&str] = &["secs_since_epoch", "nanos_since_epoch"];
- let duration = try!(deserializer.deserialize_struct("SystemTime", FIELDS, DurationVisitor));
+ let duration = tri!(deserializer.deserialize_struct("SystemTime", FIELDS, DurationVisitor));
#[cfg(not(no_systemtime_checked_add))]
let ret = UNIX_EPOCH
.checked_add(duration)
@@ -2269,7 +2227,7 @@ where
where
D: Deserializer<'de>,
{
- let (start, end) = try!(deserializer.deserialize_struct(
+ let (start, end) = tri!(deserializer.deserialize_struct(
"Range",
range::FIELDS,
range::RangeVisitor {
@@ -2281,7 +2239,6 @@ where
}
}
-#[cfg(not(no_range_inclusive))]
impl<'de, Idx> Deserialize<'de> for RangeInclusive<Idx>
where
Idx: Deserialize<'de>,
@@ -2290,7 +2247,7 @@ where
where
D: Deserializer<'de>,
{
- let (start, end) = try!(deserializer.deserialize_struct(
+ let (start, end) = tri!(deserializer.deserialize_struct(
"RangeInclusive",
range::FIELDS,
range::RangeVisitor {
@@ -2303,9 +2260,9 @@ where
}
mod range {
- use lib::*;
+ use crate::lib::*;
- use de::{Deserialize, Deserializer, Error, MapAccess, SeqAccess, Visitor};
+ use crate::de::{Deserialize, Deserializer, Error, MapAccess, SeqAccess, Visitor};
pub const FIELDS: &[&str] = &["start", "end"];
@@ -2351,7 +2308,7 @@ mod range {
b"start" => Ok(Field::Start),
b"end" => Ok(Field::End),
_ => {
- let value = ::__private::from_utf8_lossy(value);
+ let value = crate::__private::from_utf8_lossy(value);
Err(Error::unknown_field(&*value, FIELDS))
}
}
@@ -2381,13 +2338,13 @@ mod range {
where
A: SeqAccess<'de>,
{
- let start: Idx = match try!(seq.next_element()) {
+ let start: Idx = match tri!(seq.next_element()) {
Some(value) => value,
None => {
return Err(Error::invalid_length(0, &self));
}
};
- let end: Idx = match try!(seq.next_element()) {
+ let end: Idx = match tri!(seq.next_element()) {
Some(value) => value,
None => {
return Err(Error::invalid_length(1, &self));
@@ -2402,19 +2359,19 @@ mod range {
{
let mut start: Option<Idx> = None;
let mut end: Option<Idx> = None;
- while let Some(key) = try!(map.next_key()) {
+ while let Some(key) = tri!(map.next_key()) {
match key {
Field::Start => {
if start.is_some() {
return Err(<A::Error as Error>::duplicate_field("start"));
}
- start = Some(try!(map.next_value()));
+ start = Some(tri!(map.next_value()));
}
Field::End => {
if end.is_some() {
return Err(<A::Error as Error>::duplicate_field("end"));
}
- end = Some(try!(map.next_value()));
+ end = Some(tri!(map.next_value()));
}
}
}
@@ -2448,7 +2405,7 @@ where
where
D: Deserializer<'de>,
{
- let start = try!(deserializer.deserialize_struct(
+ let start = tri!(deserializer.deserialize_struct(
"RangeFrom",
range_from::FIELDS,
range_from::RangeFromVisitor {
@@ -2461,9 +2418,9 @@ where
}
mod range_from {
- use lib::*;
+ use crate::lib::*;
- use de::{Deserialize, Deserializer, Error, MapAccess, SeqAccess, Visitor};
+ use crate::de::{Deserialize, Deserializer, Error, MapAccess, SeqAccess, Visitor};
pub const FIELDS: &[&str] = &["end"];
@@ -2506,7 +2463,7 @@ mod range_from {
match value {
b"end" => Ok(Field::End),
_ => {
- let value = ::__private::from_utf8_lossy(value);
+ let value = crate::__private::from_utf8_lossy(value);
Err(Error::unknown_field(&*value, FIELDS))
}
}
@@ -2536,7 +2493,7 @@ mod range_from {
where
A: SeqAccess<'de>,
{
- let end: Idx = match try!(seq.next_element()) {
+ let end: Idx = match tri!(seq.next_element()) {
Some(value) => value,
None => {
return Err(Error::invalid_length(0, &self));
@@ -2550,13 +2507,13 @@ mod range_from {
A: MapAccess<'de>,
{
let mut end: Option<Idx> = None;
- while let Some(key) = try!(map.next_key()) {
+ while let Some(key) = tri!(map.next_key()) {
match key {
Field::End => {
if end.is_some() {
return Err(<A::Error as Error>::duplicate_field("end"));
}
- end = Some(try!(map.next_value()));
+ end = Some(tri!(map.next_value()));
}
}
}
@@ -2586,7 +2543,7 @@ where
where
D: Deserializer<'de>,
{
- let end = try!(deserializer.deserialize_struct(
+ let end = tri!(deserializer.deserialize_struct(
"RangeTo",
range_to::FIELDS,
range_to::RangeToVisitor {
@@ -2599,9 +2556,9 @@ where
}
mod range_to {
- use lib::*;
+ use crate::lib::*;
- use de::{Deserialize, Deserializer, Error, MapAccess, SeqAccess, Visitor};
+ use crate::de::{Deserialize, Deserializer, Error, MapAccess, SeqAccess, Visitor};
pub const FIELDS: &[&str] = &["start"];
@@ -2644,7 +2601,7 @@ mod range_to {
match value {
b"start" => Ok(Field::Start),
_ => {
- let value = ::__private::from_utf8_lossy(value);
+ let value = crate::__private::from_utf8_lossy(value);
Err(Error::unknown_field(&*value, FIELDS))
}
}
@@ -2674,7 +2631,7 @@ mod range_to {
where
A: SeqAccess<'de>,
{
- let start: Idx = match try!(seq.next_element()) {
+ let start: Idx = match tri!(seq.next_element()) {
Some(value) => value,
None => {
return Err(Error::invalid_length(0, &self));
@@ -2688,13 +2645,13 @@ mod range_to {
A: MapAccess<'de>,
{
let mut start: Option<Idx> = None;
- while let Some(key) = try!(map.next_key()) {
+ while let Some(key) = tri!(map.next_key()) {
match key {
Field::Start => {
if start.is_some() {
return Err(<A::Error as Error>::duplicate_field("start"));
}
- start = Some(try!(map.next_value()));
+ start = Some(tri!(map.next_value()));
}
}
}
@@ -2709,7 +2666,6 @@ mod range_to {
////////////////////////////////////////////////////////////////////////////////
-#[cfg(any(not(no_ops_bound), all(feature = "std", not(no_collections_bound))))]
impl<'de, T> Deserialize<'de> for Bound<T>
where
T: Deserialize<'de>,
@@ -2801,7 +2757,7 @@ where
where
A: EnumAccess<'de>,
{
- match try!(data.variant()) {
+ match tri!(data.variant()) {
(Field::Unbounded, v) => v.unit_variant().map(|()| Bound::Unbounded),
(Field::Included, v) => v.newtype_variant().map(Bound::Included),
(Field::Excluded, v) => v.newtype_variant().map(Bound::Excluded),
@@ -2910,7 +2866,7 @@ where
where
A: EnumAccess<'de>,
{
- match try!(data.variant()) {
+ match tri!(data.variant()) {
(Field::Ok, v) => v.newtype_variant().map(Ok),
(Field::Err, v) => v.newtype_variant().map(Err),
}
diff --git a/vendor/serde/src/de/mod.rs b/vendor/serde/src/de/mod.rs
index a04ecf77d..afbc23af6 100644
--- a/vendor/serde/src/de/mod.rs
+++ b/vendor/serde/src/de/mod.rs
@@ -112,26 +112,28 @@
//! [derive section of the manual]: https://serde.rs/derive.html
//! [data formats]: https://serde.rs/#data-formats
-use lib::*;
+use crate::lib::*;
////////////////////////////////////////////////////////////////////////////////
pub mod value;
-#[cfg(not(no_integer128))]
mod format;
mod ignored_any;
mod impls;
-mod utf8;
+pub(crate) mod size_hint;
pub use self::ignored_any::IgnoredAny;
+#[cfg(not(any(feature = "std", feature = "unstable")))]
+#[doc(no_inline)]
+pub use crate::std_error::Error as StdError;
+#[cfg(all(feature = "unstable", not(feature = "std")))]
+#[doc(no_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"))]
-#[doc(no_inline)]
-pub use std_error::Error as StdError;
////////////////////////////////////////////////////////////////////////////////
@@ -566,7 +568,7 @@ pub trait Deserialize<'de>: Sized {
D: Deserializer<'de>,
{
// Default implementation just delegates to `deserialize` impl.
- *place = try!(Deserialize::deserialize(deserializer));
+ *place = tri!(Deserialize::deserialize(deserializer));
Ok(())
}
}
@@ -946,18 +948,15 @@ pub trait Deserializer<'de>: Sized {
where
V: Visitor<'de>;
- serde_if_integer128! {
- /// Hint that the `Deserialize` type is expecting an `i128` value.
- ///
- /// This method is available only on Rust compiler versions >=1.26. The
- /// default behavior unconditionally returns an error.
- fn deserialize_i128<V>(self, visitor: V) -> Result<V::Value, Self::Error>
- where
- V: Visitor<'de>
- {
- let _ = visitor;
- Err(Error::custom("i128 is not supported"))
- }
+ /// Hint that the `Deserialize` type is expecting an `i128` value.
+ ///
+ /// The default behavior unconditionally returns an error.
+ fn deserialize_i128<V>(self, visitor: V) -> Result<V::Value, Self::Error>
+ where
+ V: Visitor<'de>,
+ {
+ let _ = visitor;
+ Err(Error::custom("i128 is not supported"))
}
/// Hint that the `Deserialize` type is expecting a `u8` value.
@@ -980,18 +979,15 @@ pub trait Deserializer<'de>: Sized {
where
V: Visitor<'de>;
- serde_if_integer128! {
- /// Hint that the `Deserialize` type is expecting an `u128` value.
- ///
- /// This method is available only on Rust compiler versions >=1.26. The
- /// default behavior unconditionally returns an error.
- fn deserialize_u128<V>(self, visitor: V) -> Result<V::Value, Self::Error>
- where
- V: Visitor<'de>
- {
- let _ = visitor;
- Err(Error::custom("u128 is not supported"))
- }
+ /// Hint that the `Deserialize` type is expecting an `u128` value.
+ ///
+ /// The default behavior unconditionally returns an error.
+ fn deserialize_u128<V>(self, visitor: V) -> Result<V::Value, Self::Error>
+ where
+ V: Visitor<'de>,
+ {
+ let _ = visitor;
+ Err(Error::custom("u128 is not supported"))
}
/// Hint that the `Deserialize` type is expecting a `f32` value.
@@ -1226,11 +1222,11 @@ pub trait Deserializer<'de>: Sized {
#[doc(hidden)]
fn __deserialize_content<V>(
self,
- _: ::actually_private::T,
+ _: crate::actually_private::T,
visitor: V,
- ) -> Result<::private::de::Content<'de>, Self::Error>
+ ) -> Result<crate::__private::de::Content<'de>, Self::Error>
where
- V: Visitor<'de, Value = ::private::de::Content<'de>>,
+ V: Visitor<'de, Value = crate::__private::de::Content<'de>>,
{
self.deserialize_any(visitor)
}
@@ -1363,20 +1359,20 @@ pub trait Visitor<'de>: Sized {
Err(Error::invalid_type(Unexpected::Signed(v), &self))
}
- serde_if_integer128! {
- /// The input contains a `i128`.
- ///
- /// This method is available only on Rust compiler versions >=1.26. The
- /// default implementation fails with a type error.
- fn visit_i128<E>(self, v: i128) -> Result<Self::Value, E>
- where
- E: Error,
- {
- let mut buf = [0u8; 58];
- let mut writer = format::Buf::new(&mut buf);
- fmt::Write::write_fmt(&mut writer, format_args!("integer `{}` as i128", v)).unwrap();
- Err(Error::invalid_type(Unexpected::Other(writer.as_str()), &self))
- }
+ /// The input contains a `i128`.
+ ///
+ /// The default implementation fails with a type error.
+ fn visit_i128<E>(self, v: i128) -> Result<Self::Value, E>
+ where
+ E: Error,
+ {
+ let mut buf = [0u8; 58];
+ let mut writer = format::Buf::new(&mut buf);
+ fmt::Write::write_fmt(&mut writer, format_args!("integer `{}` as i128", v)).unwrap();
+ Err(Error::invalid_type(
+ Unexpected::Other(writer.as_str()),
+ &self,
+ ))
}
/// The input contains a `u8`.
@@ -1425,20 +1421,20 @@ pub trait Visitor<'de>: Sized {
Err(Error::invalid_type(Unexpected::Unsigned(v), &self))
}
- serde_if_integer128! {
- /// The input contains a `u128`.
- ///
- /// This method is available only on Rust compiler versions >=1.26. The
- /// default implementation fails with a type error.
- fn visit_u128<E>(self, v: u128) -> Result<Self::Value, E>
- where
- E: Error,
- {
- let mut buf = [0u8; 57];
- let mut writer = format::Buf::new(&mut buf);
- fmt::Write::write_fmt(&mut writer, format_args!("integer `{}` as u128", v)).unwrap();
- Err(Error::invalid_type(Unexpected::Other(writer.as_str()), &self))
- }
+ /// The input contains a `u128`.
+ ///
+ /// The default implementation fails with a type error.
+ fn visit_u128<E>(self, v: u128) -> Result<Self::Value, E>
+ where
+ E: Error,
+ {
+ let mut buf = [0u8; 57];
+ let mut writer = format::Buf::new(&mut buf);
+ fmt::Write::write_fmt(&mut writer, format_args!("integer `{}` as u128", v)).unwrap();
+ Err(Error::invalid_type(
+ Unexpected::Other(writer.as_str()),
+ &self,
+ ))
}
/// The input contains an `f32`.
@@ -1474,7 +1470,7 @@ pub trait Visitor<'de>: Sized {
where
E: Error,
{
- self.visit_str(utf8::encode(v).as_str())
+ self.visit_str(v.encode_utf8(&mut [0u8; 4]))
}
/// The input contains a string. The lifetime of the string is ephemeral and
@@ -1551,7 +1547,6 @@ pub trait Visitor<'de>: Sized {
where
E: Error,
{
- let _ = v;
Err(Error::invalid_type(Unexpected::Bytes(v), &self))
}
@@ -1831,9 +1826,9 @@ pub trait MapAccess<'de> {
K: DeserializeSeed<'de>,
V: DeserializeSeed<'de>,
{
- match try!(self.next_key_seed(kseed)) {
+ match tri!(self.next_key_seed(kseed)) {
Some(key) => {
- let value = try!(self.next_value_seed(vseed));
+ let value = tri!(self.next_value_seed(vseed));
Ok(Some((key, value)))
}
None => Ok(None),
@@ -2281,12 +2276,12 @@ impl Display for OneOf {
1 => write!(formatter, "`{}`", self.names[0]),
2 => write!(formatter, "`{}` or `{}`", self.names[0], self.names[1]),
_ => {
- try!(write!(formatter, "one of "));
+ tri!(write!(formatter, "one of "));
for (i, alt) in self.names.iter().enumerate() {
if i > 0 {
- try!(write!(formatter, ", "));
+ tri!(write!(formatter, ", "));
}
- try!(write!(formatter, "`{}`", alt));
+ tri!(write!(formatter, "`{}`", alt));
}
Ok(())
}
diff --git a/vendor/serde/src/de/seed.rs b/vendor/serde/src/de/seed.rs
index 13b7ea461..52fb89d84 100644
--- a/vendor/serde/src/de/seed.rs
+++ b/vendor/serde/src/de/seed.rs
@@ -1,4 +1,4 @@
-use de::{Deserialize, DeserializeSeed, Deserializer};
+use crate::de::{Deserialize, DeserializeSeed, Deserializer};
/// A DeserializeSeed helper for implementing deserialize_in_place Visitors.
///
diff --git a/vendor/serde/src/private/size_hint.rs b/vendor/serde/src/de/size_hint.rs
index 571af496a..4a4fe25dc 100644
--- a/vendor/serde/src/private/size_hint.rs
+++ b/vendor/serde/src/de/size_hint.rs
@@ -1,4 +1,4 @@
-use lib::*;
+use crate::lib::*;
pub fn from_bounds<I>(iter: &I) -> Option<usize>
where
diff --git a/vendor/serde/src/de/utf8.rs b/vendor/serde/src/de/utf8.rs
deleted file mode 100644
index 96731cd63..000000000
--- a/vendor/serde/src/de/utf8.rs
+++ /dev/null
@@ -1,46 +0,0 @@
-use lib::*;
-
-const TAG_CONT: u8 = 0b1000_0000;
-const TAG_TWO_B: u8 = 0b1100_0000;
-const TAG_THREE_B: u8 = 0b1110_0000;
-const TAG_FOUR_B: u8 = 0b1111_0000;
-const MAX_ONE_B: u32 = 0x80;
-const MAX_TWO_B: u32 = 0x800;
-const MAX_THREE_B: u32 = 0x10000;
-
-#[inline]
-pub fn encode(c: char) -> Encode {
- let code = c as u32;
- let mut buf = [0; 4];
- let pos = if code < MAX_ONE_B {
- buf[3] = code as u8;
- 3
- } else if code < MAX_TWO_B {
- buf[2] = (code >> 6 & 0x1F) as u8 | TAG_TWO_B;
- buf[3] = (code & 0x3F) as u8 | TAG_CONT;
- 2
- } else if code < MAX_THREE_B {
- buf[1] = (code >> 12 & 0x0F) as u8 | TAG_THREE_B;
- buf[2] = (code >> 6 & 0x3F) as u8 | TAG_CONT;
- buf[3] = (code & 0x3F) as u8 | TAG_CONT;
- 1
- } else {
- buf[0] = (code >> 18 & 0x07) as u8 | TAG_FOUR_B;
- buf[1] = (code >> 12 & 0x3F) as u8 | TAG_CONT;
- buf[2] = (code >> 6 & 0x3F) as u8 | TAG_CONT;
- buf[3] = (code & 0x3F) as u8 | TAG_CONT;
- 0
- };
- Encode { buf, pos }
-}
-
-pub struct Encode {
- buf: [u8; 4],
- pos: usize,
-}
-
-impl Encode {
- pub fn as_str(&self) -> &str {
- str::from_utf8(&self.buf[self.pos..]).unwrap()
- }
-}
diff --git a/vendor/serde/src/de/value.rs b/vendor/serde/src/de/value.rs
index 392f8a239..1234b8103 100644
--- a/vendor/serde/src/de/value.rs
+++ b/vendor/serde/src/de/value.rs
@@ -21,12 +21,11 @@
//! }
//! ```
-use lib::*;
+use crate::lib::*;
use self::private::{First, Second};
-use __private::size_hint;
-use de::{self, Deserializer, Expected, IntoDeserializer, SeqAccess, Visitor};
-use ser;
+use crate::de::{self, size_hint, Deserializer, Expected, IntoDeserializer, SeqAccess, Visitor};
+use crate::ser;
////////////////////////////////////////////////////////////////////////////////
@@ -293,20 +292,17 @@ primitive_deserializer!(i8, "an `i8`.", I8Deserializer, visit_i8);
primitive_deserializer!(i16, "an `i16`.", I16Deserializer, visit_i16);
primitive_deserializer!(i32, "an `i32`.", I32Deserializer, visit_i32);
primitive_deserializer!(i64, "an `i64`.", I64Deserializer, visit_i64);
+primitive_deserializer!(i128, "an `i128`.", I128Deserializer, visit_i128);
primitive_deserializer!(isize, "an `isize`.", IsizeDeserializer, visit_i64 as i64);
primitive_deserializer!(u8, "a `u8`.", U8Deserializer, visit_u8);
primitive_deserializer!(u16, "a `u16`.", U16Deserializer, visit_u16);
primitive_deserializer!(u64, "a `u64`.", U64Deserializer, visit_u64);
+primitive_deserializer!(u128, "a `u128`.", U128Deserializer, visit_u128);
primitive_deserializer!(usize, "a `usize`.", UsizeDeserializer, visit_u64 as u64);
primitive_deserializer!(f32, "an `f32`.", F32Deserializer, visit_f32);
primitive_deserializer!(f64, "an `f64`.", F64Deserializer, visit_f64);
primitive_deserializer!(char, "a `char`.", CharDeserializer, visit_char);
-serde_if_integer128! {
- primitive_deserializer!(i128, "an `i128`.", I128Deserializer, visit_i128);
- primitive_deserializer!(u128, "a `u128`.", U128Deserializer, visit_u128);
-}
-
/// A deserializer holding a `u32`.
pub struct U32Deserializer<E> {
value: u32,
@@ -937,8 +933,8 @@ where
where
V: de::Visitor<'de>,
{
- let v = try!(visitor.visit_seq(&mut self));
- try!(self.end());
+ let v = tri!(visitor.visit_seq(&mut self));
+ tri!(self.end());
Ok(v)
}
@@ -1162,8 +1158,8 @@ where
where
V: de::Visitor<'de>,
{
- let value = try!(visitor.visit_map(&mut self));
- try!(self.end());
+ let value = tri!(visitor.visit_map(&mut self));
+ tri!(self.end());
Ok(value)
}
@@ -1171,8 +1167,8 @@ where
where
V: de::Visitor<'de>,
{
- let value = try!(visitor.visit_seq(&mut self));
- try!(self.end());
+ let value = tri!(visitor.visit_seq(&mut self));
+ tri!(self.end());
Ok(value)
}
@@ -1236,8 +1232,8 @@ where
{
match self.next_pair() {
Some((key, value)) => {
- let key = try!(kseed.deserialize(key.into_deserializer()));
- let value = try!(vseed.deserialize(value.into_deserializer()));
+ let key = tri!(kseed.deserialize(key.into_deserializer()));
+ let value = tri!(vseed.deserialize(value.into_deserializer()));
Ok(Some((key, value)))
}
None => Ok(None),
@@ -1341,7 +1337,7 @@ where
V: de::Visitor<'de>,
{
let mut pair_visitor = PairVisitor(Some(self.0), Some(self.1), PhantomData);
- let pair = try!(visitor.visit_seq(&mut pair_visitor));
+ let pair = tri!(visitor.visit_seq(&mut pair_visitor));
if pair_visitor.1.is_none() {
Ok(pair)
} else {
@@ -1501,7 +1497,7 @@ where
where
T: de::DeserializeSeed<'de>,
{
- match try!(self.map.next_key_seed(seed)) {
+ match tri!(self.map.next_key_seed(seed)) {
Some(key) => Ok((key, private::map_as_enum(self.map))),
None => Err(de::Error::invalid_type(de::Unexpected::Map, &"enum")),
}
@@ -1546,9 +1542,11 @@ where
////////////////////////////////////////////////////////////////////////////////
mod private {
- use lib::*;
+ use crate::lib::*;
- use de::{self, DeserializeSeed, Deserializer, MapAccess, Unexpected, VariantAccess, Visitor};
+ use crate::de::{
+ self, DeserializeSeed, Deserializer, MapAccess, Unexpected, VariantAccess, Visitor,
+ };
pub struct UnitOnly<E> {
marker: PhantomData<E>,
diff --git a/vendor/serde/src/integer128.rs b/vendor/serde/src/integer128.rs
index a51291be6..2f94a644b 100644
--- a/vendor/serde/src/integer128.rs
+++ b/vendor/serde/src/integer128.rs
@@ -1,82 +1,9 @@
-/// Conditional compilation depending on whether Serde is built with support for
-/// 128-bit integers.
-///
-/// Data formats that wish to support Rust compiler versions older than 1.26
-/// (or targets that lack 128-bit integers) may place the i128 / u128 methods
-/// of their Serializer and Deserializer behind this macro.
-///
-/// Data formats that require a minimum Rust compiler version of at least 1.26,
-/// or do not target platforms that lack 128-bit integers, do not need to
-/// bother with this macro and may assume support for 128-bit integers.
-///
-/// ```edition2021
-/// # use serde::__private::doc::Error;
-/// #
-/// # struct MySerializer;
-/// #
-/// use serde::{serde_if_integer128, Serializer};
-///
-/// impl Serializer for MySerializer {
-/// type Ok = ();
-/// type Error = Error;
-///
-/// fn serialize_i64(self, v: i64) -> Result<Self::Ok, Self::Error> {
-/// /* ... */
-/// # unimplemented!()
-/// }
-///
-/// /* ... */
-///
-/// serde_if_integer128! {
-/// fn serialize_i128(self, v: i128) -> Result<Self::Ok, Self::Error> {
-/// /* ... */
-/// # unimplemented!()
-/// }
-///
-/// fn serialize_u128(self, v: u128) -> Result<Self::Ok, Self::Error> {
-/// /* ... */
-/// # unimplemented!()
-/// }
-/// }
-/// #
-/// # serde::__serialize_unimplemented! {
-/// # bool i8 i16 i32 u8 u16 u32 u64 f32 f64 char str bytes none some
-/// # unit unit_struct unit_variant newtype_struct newtype_variant seq
-/// # tuple tuple_struct tuple_variant map struct struct_variant
-/// # }
-/// }
-/// ```
-///
-/// When Serde is built with support for 128-bit integers, this macro expands
-/// transparently into just the input tokens.
-///
-/// ```edition2021
-/// macro_rules! serde_if_integer128 {
-/// ($($tt:tt)*) => {
-/// $($tt)*
-/// };
-/// }
-/// ```
-///
-/// When built without support for 128-bit integers, this macro expands to
-/// nothing.
-///
-/// ```edition2021
-/// macro_rules! serde_if_integer128 {
-/// ($($tt:tt)*) => {};
-/// }
-/// ```
-#[cfg(not(no_integer128))]
+// No longer used. Old versions of serde used this macro for supporting targets
+// that did not yet have 128-bit integer support.
#[macro_export]
+#[doc(hidden)]
macro_rules! serde_if_integer128 {
($($tt:tt)*) => {
$($tt)*
};
}
-
-#[cfg(no_integer128)]
-#[macro_export]
-#[doc(hidden)]
-macro_rules! serde_if_integer128 {
- ($($tt:tt)*) => {};
-}
diff --git a/vendor/serde/src/lib.rs b/vendor/serde/src/lib.rs
index 992633b8c..f7d445749 100644
--- a/vendor/serde/src/lib.rs
+++ b/vendor/serde/src/lib.rs
@@ -93,7 +93,7 @@
////////////////////////////////////////////////////////////////////////////////
// Serde types in rustdoc of other crates get linked to here.
-#![doc(html_root_url = "https://docs.rs/serde/1.0.171")]
+#![doc(html_root_url = "https://docs.rs/serde/1.0.188")]
// Support using Serde without the standard library!
#![cfg_attr(not(feature = "std"), no_std)]
// Unstable functionality only if the user asks for it. For tracking and
@@ -102,53 +102,51 @@
// https://github.com/serde-rs/serde/issues/812
#![cfg_attr(feature = "unstable", feature(error_in_core, never_type))]
#![allow(unknown_lints, bare_trait_objects, deprecated)]
-#![cfg_attr(feature = "cargo-clippy", allow(renamed_and_removed_lints))]
// Ignored clippy and clippy_pedantic lints
-#![cfg_attr(
- feature = "cargo-clippy",
- allow(
- // clippy bug: https://github.com/rust-lang/rust-clippy/issues/5704
- unnested_or_patterns,
- // clippy bug: https://github.com/rust-lang/rust-clippy/issues/7768
- semicolon_if_nothing_returned,
- // not available in our oldest supported compiler
- empty_enum,
- type_repetition_in_bounds, // https://github.com/rust-lang/rust-clippy/issues/8772
- // integer and float ser/de requires these sorts of casts
- cast_possible_truncation,
- cast_possible_wrap,
- cast_sign_loss,
- // things are often more readable this way
- cast_lossless,
- module_name_repetitions,
- option_if_let_else,
- single_match_else,
- type_complexity,
- use_self,
- zero_prefixed_literal,
- // correctly used
- derive_partial_eq_without_eq,
- enum_glob_use,
- explicit_auto_deref,
- let_underscore_untyped,
- map_err_ignore,
- new_without_default,
- result_unit_err,
- wildcard_imports,
- // not practical
- needless_pass_by_value,
- similar_names,
- too_many_lines,
- // preference
- doc_markdown,
- unseparated_literal_suffix,
- // false positive
- needless_doctest_main,
- // noisy
- missing_errors_doc,
- must_use_candidate,
- )
+#![allow(
+ // clippy bug: https://github.com/rust-lang/rust-clippy/issues/5704
+ clippy::unnested_or_patterns,
+ // clippy bug: https://github.com/rust-lang/rust-clippy/issues/7768
+ clippy::semicolon_if_nothing_returned,
+ // not available in our oldest supported compiler
+ clippy::empty_enum,
+ clippy::type_repetition_in_bounds, // https://github.com/rust-lang/rust-clippy/issues/8772
+ // integer and float ser/de requires these sorts of casts
+ clippy::cast_possible_truncation,
+ clippy::cast_possible_wrap,
+ clippy::cast_sign_loss,
+ // things are often more readable this way
+ clippy::cast_lossless,
+ clippy::module_name_repetitions,
+ clippy::option_if_let_else,
+ clippy::single_match_else,
+ clippy::type_complexity,
+ clippy::use_self,
+ clippy::zero_prefixed_literal,
+ // correctly used
+ clippy::derive_partial_eq_without_eq,
+ clippy::enum_glob_use,
+ clippy::explicit_auto_deref,
+ clippy::let_underscore_untyped,
+ clippy::map_err_ignore,
+ clippy::new_without_default,
+ clippy::result_unit_err,
+ clippy::wildcard_imports,
+ // not practical
+ clippy::needless_pass_by_value,
+ clippy::similar_names,
+ clippy::too_many_lines,
+ // preference
+ clippy::doc_markdown,
+ clippy::unseparated_literal_suffix,
+ // false positive
+ clippy::needless_doctest_main,
+ // noisy
+ clippy::missing_errors_doc,
+ clippy::must_use_candidate,
)]
+// Restrictions
+#![deny(clippy::question_mark_used)]
// Rustc lints.
#![deny(missing_docs, unused_imports)]
@@ -175,14 +173,16 @@ mod lib {
pub use self::core::cell::{Cell, RefCell};
pub use self::core::clone::{self, Clone};
+ pub use self::core::cmp::Reverse;
pub use self::core::convert::{self, From, Into};
pub use self::core::default::{self, Default};
pub use self::core::fmt::{self, Debug, Display};
pub use self::core::marker::{self, PhantomData};
pub use self::core::num::Wrapping;
- pub use self::core::ops::{Range, RangeFrom, RangeTo};
+ pub use self::core::ops::{Bound, Range, RangeFrom, RangeInclusive, RangeTo};
pub use self::core::option::{self, Option};
pub use self::core::result::{self, Result};
+ pub use self::core::time::Duration;
#[cfg(all(feature = "alloc", not(feature = "std")))]
pub use alloc::borrow::{Cow, ToOwned};
@@ -220,7 +220,7 @@ mod lib {
pub use std::collections::{BTreeMap, BTreeSet, BinaryHeap, LinkedList, VecDeque};
#[cfg(all(not(no_core_cstr), not(feature = "std")))]
- pub use core::ffi::CStr;
+ pub use self::core::ffi::CStr;
#[cfg(feature = "std")]
pub use std::ffi::CStr;
@@ -247,18 +247,6 @@ mod lib {
#[cfg(feature = "std")]
pub use std::time::{SystemTime, UNIX_EPOCH};
- #[cfg(all(feature = "std", not(no_collections_bound), no_ops_bound))]
- pub use std::collections::Bound;
-
- #[cfg(not(no_core_reverse))]
- pub use self::core::cmp::Reverse;
-
- #[cfg(not(no_ops_bound))]
- pub use self::core::ops::Bound;
-
- #[cfg(not(no_range_inclusive))]
- pub use self::core::ops::RangeInclusive;
-
#[cfg(all(feature = "std", no_target_has_atomic, not(no_std_atomic)))]
pub use std::sync::atomic::{
AtomicBool, AtomicI16, AtomicI32, AtomicI8, AtomicIsize, AtomicU16, AtomicU32, AtomicU8,
@@ -279,16 +267,13 @@ mod lib {
pub use std::sync::atomic::{AtomicI64, AtomicU64};
#[cfg(all(feature = "std", not(no_target_has_atomic), target_has_atomic = "ptr"))]
pub use std::sync::atomic::{AtomicIsize, AtomicUsize};
-
- #[cfg(any(feature = "std", not(no_core_duration)))]
- pub use self::core::time::Duration;
}
// None of this crate's error handling needs the `From::from` error conversion
// performed implicitly by the `?` operator or the standard library's `try!`
// macro. This simplified macro gives a 5.5% improvement in compile time
// compared to standard `try!`, and 9% improvement compared to `?`.
-macro_rules! try {
+macro_rules! tri {
($expr:expr) => {
match $expr {
Ok(val) => val,
@@ -309,20 +294,15 @@ pub mod de;
pub mod ser;
#[doc(inline)]
-pub use de::{Deserialize, Deserializer};
+pub use crate::de::{Deserialize, Deserializer};
#[doc(inline)]
-pub use ser::{Serialize, Serializer};
+pub use crate::ser::{Serialize, Serializer};
// Used by generated code and doc tests. Not public API.
#[doc(hidden)]
#[path = "private/mod.rs"]
pub mod __private;
-#[allow(unused_imports)]
-use self::__private as export;
-#[allow(unused_imports)]
-use self::__private as private;
-
#[path = "de/seed.rs"]
mod seed;
@@ -335,8 +315,6 @@ mod std_error;
// be annoying for crates that provide handwritten impls or data formats. They
// would need to disable default features and then explicitly re-enable std.
#[cfg(feature = "serde_derive")]
-#[allow(unused_imports)]
-#[macro_use]
extern crate serde_derive;
/// Derive macro available if serde is built with `features = ["derive"]`.
diff --git a/vendor/serde/src/macros.rs b/vendor/serde/src/macros.rs
index 71ddc1503..a8fd85a37 100644
--- a/vendor/serde/src/macros.rs
+++ b/vendor/serde/src/macros.rs
@@ -154,9 +154,7 @@ macro_rules! forward_to_deserialize_any_helper {
forward_to_deserialize_any_method!{deserialize_i64<$l, $v>()}
};
(i128<$l:tt, $v:ident>) => {
- serde_if_integer128! {
- forward_to_deserialize_any_method!{deserialize_i128<$l, $v>()}
- }
+ forward_to_deserialize_any_method!{deserialize_i128<$l, $v>()}
};
(u8<$l:tt, $v:ident>) => {
forward_to_deserialize_any_method!{deserialize_u8<$l, $v>()}
@@ -171,9 +169,7 @@ macro_rules! forward_to_deserialize_any_helper {
forward_to_deserialize_any_method!{deserialize_u64<$l, $v>()}
};
(u128<$l:tt, $v:ident>) => {
- serde_if_integer128! {
- forward_to_deserialize_any_method!{deserialize_u128<$l, $v>()}
- }
+ forward_to_deserialize_any_method!{deserialize_u128<$l, $v>()}
};
(f32<$l:tt, $v:ident>) => {
forward_to_deserialize_any_method!{deserialize_f32<$l, $v>()}
diff --git a/vendor/serde/src/private/de.rs b/vendor/serde/src/private/de.rs
index 3c0a187ac..883e6909c 100644
--- a/vendor/serde/src/private/de.rs
+++ b/vendor/serde/src/private/de.rs
@@ -1,10 +1,13 @@
-use lib::*;
+use crate::lib::*;
-use de::value::{BorrowedBytesDeserializer, BytesDeserializer};
-use de::{Deserialize, Deserializer, Error, IntoDeserializer, Visitor};
+use crate::de::value::{BorrowedBytesDeserializer, BytesDeserializer};
+use crate::de::{
+ Deserialize, DeserializeSeed, Deserializer, EnumAccess, Error, IntoDeserializer, VariantAccess,
+ Visitor,
+};
#[cfg(any(feature = "std", feature = "alloc"))]
-use de::{DeserializeSeed, MapAccess, Unexpected};
+use crate::de::{MapAccess, Unexpected};
#[cfg(any(feature = "std", feature = "alloc"))]
pub use self::content::{
@@ -13,7 +16,7 @@ pub use self::content::{
TagOrContentField, TagOrContentFieldVisitor, TaggedContentVisitor, UntaggedUnitVisitor,
};
-pub use seed::InPlaceSeed;
+pub use crate::seed::InPlaceSeed;
/// If the missing field is of type `Option<T>` then treat is as `None`,
/// otherwise it is an error.
@@ -203,13 +206,13 @@ mod content {
// This issue is tracking making some of this stuff public:
// https://github.com/serde-rs/serde/issues/741
- use lib::*;
+ use crate::lib::*;
- use __private::size_hint;
- use actually_private;
- use de::{
- self, Deserialize, DeserializeSeed, Deserializer, EnumAccess, Expected, IgnoredAny,
- MapAccess, SeqAccess, Unexpected, Visitor,
+ use crate::actually_private;
+ use crate::de::value::{MapDeserializer, SeqDeserializer};
+ use crate::de::{
+ self, size_hint, Deserialize, DeserializeSeed, Deserializer, EnumAccess, Expected,
+ IgnoredAny, MapAccess, SeqAccess, Unexpected, Visitor,
};
/// Used from generated code to buffer the contents of the Deserializer when
@@ -299,6 +302,17 @@ mod content {
}
}
+ impl<'de, E> de::IntoDeserializer<'de, E> for Content<'de>
+ where
+ E: de::Error,
+ {
+ type Deserializer = ContentDeserializer<'de, E>;
+
+ fn into_deserializer(self) -> Self::Deserializer {
+ ContentDeserializer::new(self)
+ }
+ }
+
struct ContentVisitor<'de> {
value: PhantomData<Content<'de>>,
}
@@ -476,7 +490,7 @@ mod content {
{
let mut vec =
Vec::<Content>::with_capacity(size_hint::cautious::<Content>(visitor.size_hint()));
- while let Some(e) = try!(visitor.next_element()) {
+ while let Some(e) = tri!(visitor.next_element()) {
vec.push(e);
}
Ok(Content::Seq(vec))
@@ -490,7 +504,7 @@ mod content {
Vec::<(Content, Content)>::with_capacity(
size_hint::cautious::<(Content, Content)>(visitor.size_hint()),
);
- while let Some(kv) = try!(visitor.next_entry()) {
+ while let Some(kv) = tri!(visitor.next_entry()) {
vec.push(kv);
}
Ok(Content::Map(vec))
@@ -833,14 +847,14 @@ mod content {
where
S: SeqAccess<'de>,
{
- let tag = match try!(seq.next_element()) {
+ let tag = match tri!(seq.next_element()) {
Some(tag) => tag,
None => {
return Err(de::Error::missing_field(self.tag_name));
}
};
let rest = de::value::SeqAccessDeserializer::new(seq);
- Ok((tag, try!(Content::deserialize(rest))))
+ Ok((tag, tri!(Content::deserialize(rest))))
}
fn visit_map<M>(self, mut map: M) -> Result<Self::Value, M::Error>
@@ -852,16 +866,16 @@ mod content {
Content,
Content,
)>(map.size_hint()));
- while let Some(k) = try!(map.next_key_seed(TagOrContentVisitor::new(self.tag_name))) {
+ while let Some(k) = tri!(map.next_key_seed(TagOrContentVisitor::new(self.tag_name))) {
match k {
TagOrContent::Tag => {
if tag.is_some() {
return Err(de::Error::duplicate_field(self.tag_name));
}
- tag = Some(try!(map.next_value()));
+ tag = Some(tri!(map.next_value()));
}
TagOrContent::Content(k) => {
- let v = try!(map.next_value());
+ let v = tri!(map.next_value());
vec.push((k, v));
}
}
@@ -1074,9 +1088,9 @@ mod content {
E: de::Error,
{
let seq = content.into_iter().map(ContentDeserializer::new);
- let mut seq_visitor = de::value::SeqDeserializer::new(seq);
- let value = try!(visitor.visit_seq(&mut seq_visitor));
- try!(seq_visitor.end());
+ let mut seq_visitor = SeqDeserializer::new(seq);
+ let value = tri!(visitor.visit_seq(&mut seq_visitor));
+ tri!(seq_visitor.end());
Ok(value)
}
@@ -1091,9 +1105,9 @@ mod content {
let map = content
.into_iter()
.map(|(k, v)| (ContentDeserializer::new(k), ContentDeserializer::new(v)));
- let mut map_visitor = de::value::MapDeserializer::new(map);
- let value = try!(visitor.visit_map(&mut map_visitor));
- try!(map_visitor.end());
+ let mut map_visitor = MapDeserializer::new(map);
+ let value = tri!(visitor.visit_map(&mut map_visitor));
+ tri!(map_visitor.end());
Ok(value)
}
@@ -1569,7 +1583,7 @@ mod content {
{
match self.value {
Some(Content::Seq(v)) => {
- de::Deserializer::deserialize_any(SeqDeserializer::new(v), visitor)
+ de::Deserializer::deserialize_any(SeqDeserializer::new(v.into_iter()), visitor)
}
Some(other) => Err(de::Error::invalid_type(
other.unexpected(),
@@ -1592,10 +1606,10 @@ mod content {
{
match self.value {
Some(Content::Map(v)) => {
- de::Deserializer::deserialize_any(MapDeserializer::new(v), visitor)
+ de::Deserializer::deserialize_any(MapDeserializer::new(v.into_iter()), visitor)
}
Some(Content::Seq(v)) => {
- de::Deserializer::deserialize_any(SeqDeserializer::new(v), visitor)
+ de::Deserializer::deserialize_any(SeqDeserializer::new(v.into_iter()), visitor)
}
Some(other) => Err(de::Error::invalid_type(
other.unexpected(),
@@ -1609,156 +1623,6 @@ mod content {
}
}
- struct SeqDeserializer<'de, E>
- where
- E: de::Error,
- {
- iter: <Vec<Content<'de>> as IntoIterator>::IntoIter,
- err: PhantomData<E>,
- }
-
- impl<'de, E> SeqDeserializer<'de, E>
- where
- E: de::Error,
- {
- fn new(vec: Vec<Content<'de>>) -> Self {
- SeqDeserializer {
- iter: vec.into_iter(),
- err: PhantomData,
- }
- }
- }
-
- impl<'de, E> de::Deserializer<'de> for SeqDeserializer<'de, E>
- where
- E: de::Error,
- {
- type Error = E;
-
- #[inline]
- fn deserialize_any<V>(mut self, visitor: V) -> Result<V::Value, Self::Error>
- where
- V: de::Visitor<'de>,
- {
- let len = self.iter.len();
- if len == 0 {
- visitor.visit_unit()
- } else {
- let ret = try!(visitor.visit_seq(&mut self));
- let remaining = self.iter.len();
- if remaining == 0 {
- Ok(ret)
- } else {
- Err(de::Error::invalid_length(len, &"fewer elements in array"))
- }
- }
- }
-
- forward_to_deserialize_any! {
- bool i8 i16 i32 i64 i128 u8 u16 u32 u64 u128 f32 f64 char str string
- bytes byte_buf option unit unit_struct newtype_struct seq tuple
- tuple_struct map struct enum identifier ignored_any
- }
- }
-
- impl<'de, E> de::SeqAccess<'de> for SeqDeserializer<'de, E>
- where
- E: de::Error,
- {
- type Error = E;
-
- fn next_element_seed<T>(&mut self, seed: T) -> Result<Option<T::Value>, Self::Error>
- where
- T: de::DeserializeSeed<'de>,
- {
- match self.iter.next() {
- Some(value) => seed.deserialize(ContentDeserializer::new(value)).map(Some),
- None => Ok(None),
- }
- }
-
- fn size_hint(&self) -> Option<usize> {
- size_hint::from_bounds(&self.iter)
- }
- }
-
- struct MapDeserializer<'de, E>
- where
- E: de::Error,
- {
- iter: <Vec<(Content<'de>, Content<'de>)> as IntoIterator>::IntoIter,
- value: Option<Content<'de>>,
- err: PhantomData<E>,
- }
-
- impl<'de, E> MapDeserializer<'de, E>
- where
- E: de::Error,
- {
- fn new(map: Vec<(Content<'de>, Content<'de>)>) -> Self {
- MapDeserializer {
- iter: map.into_iter(),
- value: None,
- err: PhantomData,
- }
- }
- }
-
- impl<'de, E> de::MapAccess<'de> for MapDeserializer<'de, E>
- where
- E: de::Error,
- {
- type Error = E;
-
- fn next_key_seed<T>(&mut self, seed: T) -> Result<Option<T::Value>, Self::Error>
- where
- T: de::DeserializeSeed<'de>,
- {
- match self.iter.next() {
- Some((key, value)) => {
- self.value = Some(value);
- seed.deserialize(ContentDeserializer::new(key)).map(Some)
- }
- None => Ok(None),
- }
- }
-
- fn next_value_seed<T>(&mut self, seed: T) -> Result<T::Value, Self::Error>
- where
- T: de::DeserializeSeed<'de>,
- {
- match self.value.take() {
- Some(value) => seed.deserialize(ContentDeserializer::new(value)),
- None => Err(de::Error::custom("value is missing")),
- }
- }
-
- fn size_hint(&self) -> Option<usize> {
- size_hint::from_bounds(&self.iter)
- }
- }
-
- impl<'de, E> de::Deserializer<'de> for MapDeserializer<'de, E>
- where
- E: de::Error,
- {
- type Error = E;
-
- #[inline]
- fn deserialize_any<V>(self, visitor: V) -> Result<V::Value, Self::Error>
- where
- V: de::Visitor<'de>,
- {
- visitor.visit_map(self)
- }
-
- forward_to_deserialize_any! {
- bool i8 i16 i32 i64 i128 u8 u16 u32 u64 u128 f32 f64 char str string
- bytes byte_buf option unit unit_struct newtype_struct seq tuple
- tuple_struct map struct enum identifier ignored_any
- }
- }
-
/// Not public API.
pub struct ContentRefDeserializer<'a, 'de: 'a, E> {
content: &'a Content<'de>,
@@ -1820,9 +1684,9 @@ mod content {
E: de::Error,
{
let seq = content.iter().map(ContentRefDeserializer::new);
- let mut seq_visitor = de::value::SeqDeserializer::new(seq);
- let value = try!(visitor.visit_seq(&mut seq_visitor));
- try!(seq_visitor.end());
+ let mut seq_visitor = SeqDeserializer::new(seq);
+ let value = tri!(visitor.visit_seq(&mut seq_visitor));
+ tri!(seq_visitor.end());
Ok(value)
}
@@ -1840,9 +1704,9 @@ mod content {
ContentRefDeserializer::new(v),
)
});
- let mut map_visitor = de::value::MapDeserializer::new(map);
- let value = try!(visitor.visit_map(&mut map_visitor));
- try!(map_visitor.end());
+ let mut map_visitor = MapDeserializer::new(map);
+ let value = tri!(visitor.visit_map(&mut map_visitor));
+ tri!(map_visitor.end());
Ok(value)
}
@@ -2362,7 +2226,7 @@ mod content {
if len == 0 {
visitor.visit_unit()
} else {
- let ret = try!(visitor.visit_seq(&mut self));
+ let ret = tri!(visitor.visit_seq(&mut self));
let remaining = self.iter.len();
if remaining == 0 {
Ok(ret)
@@ -2541,7 +2405,7 @@ mod content {
where
M: MapAccess<'de>,
{
- while try!(access.next_entry::<IgnoredAny, IgnoredAny>()).is_some() {}
+ while tri!(access.next_entry::<IgnoredAny, IgnoredAny>()).is_some() {}
Ok(())
}
}
@@ -2974,3 +2838,55 @@ fn flat_map_take_entry<'de>(
None
}
}
+
+pub struct AdjacentlyTaggedEnumVariantSeed<F> {
+ pub enum_name: &'static str,
+ pub variants: &'static [&'static str],
+ pub fields_enum: PhantomData<F>,
+}
+
+pub struct AdjacentlyTaggedEnumVariantVisitor<F> {
+ enum_name: &'static str,
+ fields_enum: PhantomData<F>,
+}
+
+impl<'de, F> Visitor<'de> for AdjacentlyTaggedEnumVariantVisitor<F>
+where
+ F: Deserialize<'de>,
+{
+ type Value = F;
+
+ fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
+ write!(formatter, "variant of enum {}", self.enum_name)
+ }
+
+ fn visit_enum<A>(self, data: A) -> Result<Self::Value, A::Error>
+ where
+ A: EnumAccess<'de>,
+ {
+ let (variant, variant_access) = tri!(data.variant());
+ tri!(variant_access.unit_variant());
+ Ok(variant)
+ }
+}
+
+impl<'de, F> DeserializeSeed<'de> for AdjacentlyTaggedEnumVariantSeed<F>
+where
+ F: Deserialize<'de>,
+{
+ type Value = F;
+
+ fn deserialize<D>(self, deserializer: D) -> Result<Self::Value, D::Error>
+ where
+ D: Deserializer<'de>,
+ {
+ deserializer.deserialize_enum(
+ self.enum_name,
+ self.variants,
+ AdjacentlyTaggedEnumVariantVisitor {
+ enum_name: self.enum_name,
+ fields_enum: PhantomData,
+ },
+ )
+ }
+}
diff --git a/vendor/serde/src/private/doc.rs b/vendor/serde/src/private/doc.rs
index f597af844..1b18fe6b4 100644
--- a/vendor/serde/src/private/doc.rs
+++ b/vendor/serde/src/private/doc.rs
@@ -1,8 +1,8 @@
// Used only by Serde doc tests. Not public API.
-use lib::*;
+use crate::lib::*;
-use ser;
+use crate::ser;
#[doc(hidden)]
#[derive(Debug)]
diff --git a/vendor/serde/src/private/mod.rs b/vendor/serde/src/private/mod.rs
index e89690236..177f8501b 100644
--- a/vendor/serde/src/private/mod.rs
+++ b/vendor/serde/src/private/mod.rs
@@ -3,30 +3,28 @@ pub mod de;
#[cfg(not(no_serde_derive))]
pub mod ser;
-pub mod size_hint;
-
// FIXME: #[cfg(doctest)] once https://github.com/rust-lang/rust/issues/67295 is fixed.
pub mod doc;
-pub use lib::clone::Clone;
-pub use lib::convert::{From, Into};
-pub use lib::default::Default;
-pub use lib::fmt::{self, Formatter};
-pub use lib::marker::PhantomData;
-pub use lib::option::Option::{self, None, Some};
-pub use lib::ptr;
-pub use lib::result::Result::{self, Err, Ok};
+pub use crate::lib::clone::Clone;
+pub use crate::lib::convert::{From, Into};
+pub use crate::lib::default::Default;
+pub use crate::lib::fmt::{self, Formatter};
+pub use crate::lib::marker::PhantomData;
+pub use crate::lib::option::Option::{self, None, Some};
+pub use crate::lib::ptr;
+pub use crate::lib::result::Result::{self, Err, Ok};
pub use self::string::from_utf8_lossy;
#[cfg(any(feature = "alloc", feature = "std"))]
-pub use lib::{ToString, Vec};
+pub use crate::lib::{ToString, Vec};
#[cfg(not(no_core_try_from))]
-pub use lib::convert::TryFrom;
+pub use crate::lib::convert::TryFrom;
mod string {
- use lib::*;
+ use crate::lib::*;
#[cfg(any(feature = "std", feature = "alloc"))]
pub fn from_utf8_lossy(bytes: &[u8]) -> Cow<str> {
diff --git a/vendor/serde/src/private/ser.rs b/vendor/serde/src/private/ser.rs
index 4dd45edae..50bcb251e 100644
--- a/vendor/serde/src/private/ser.rs
+++ b/vendor/serde/src/private/ser.rs
@@ -1,6 +1,6 @@
-use lib::*;
+use crate::lib::*;
-use ser::{self, Impossible, Serialize, SerializeMap, SerializeStruct, Serializer};
+use crate::ser::{self, Impossible, Serialize, SerializeMap, SerializeStruct, Serializer};
#[cfg(any(feature = "std", feature = "alloc"))]
use self::content::{
@@ -182,14 +182,14 @@ where
}
fn serialize_unit(self) -> Result<Self::Ok, Self::Error> {
- let mut map = try!(self.delegate.serialize_map(Some(1)));
- try!(map.serialize_entry(self.tag, self.variant_name));
+ let mut map = tri!(self.delegate.serialize_map(Some(1)));
+ tri!(map.serialize_entry(self.tag, self.variant_name));
map.end()
}
fn serialize_unit_struct(self, _: &'static str) -> Result<Self::Ok, Self::Error> {
- let mut map = try!(self.delegate.serialize_map(Some(1)));
- try!(map.serialize_entry(self.tag, self.variant_name));
+ let mut map = tri!(self.delegate.serialize_map(Some(1)));
+ tri!(map.serialize_entry(self.tag, self.variant_name));
map.end()
}
@@ -199,9 +199,9 @@ where
_: u32,
inner_variant: &'static str,
) -> Result<Self::Ok, Self::Error> {
- let mut map = try!(self.delegate.serialize_map(Some(2)));
- try!(map.serialize_entry(self.tag, self.variant_name));
- try!(map.serialize_entry(inner_variant, &()));
+ let mut map = tri!(self.delegate.serialize_map(Some(2)));
+ tri!(map.serialize_entry(self.tag, self.variant_name));
+ tri!(map.serialize_entry(inner_variant, &()));
map.end()
}
@@ -226,9 +226,9 @@ where
where
T: Serialize,
{
- let mut map = try!(self.delegate.serialize_map(Some(2)));
- try!(map.serialize_entry(self.tag, self.variant_name));
- try!(map.serialize_entry(inner_variant, inner_value));
+ let mut map = tri!(self.delegate.serialize_map(Some(2)));
+ tri!(map.serialize_entry(self.tag, self.variant_name));
+ tri!(map.serialize_entry(inner_variant, inner_value));
map.end()
}
@@ -269,9 +269,9 @@ where
inner_variant: &'static str,
len: usize,
) -> Result<Self::SerializeTupleVariant, Self::Error> {
- let mut map = try!(self.delegate.serialize_map(Some(2)));
- try!(map.serialize_entry(self.tag, self.variant_name));
- try!(map.serialize_key(inner_variant));
+ let mut map = tri!(self.delegate.serialize_map(Some(2)));
+ tri!(map.serialize_entry(self.tag, self.variant_name));
+ tri!(map.serialize_key(inner_variant));
Ok(SerializeTupleVariantAsMapValue::new(
map,
inner_variant,
@@ -280,8 +280,8 @@ where
}
fn serialize_map(self, len: Option<usize>) -> Result<Self::SerializeMap, Self::Error> {
- let mut map = try!(self.delegate.serialize_map(len.map(|len| len + 1)));
- try!(map.serialize_entry(self.tag, self.variant_name));
+ let mut map = tri!(self.delegate.serialize_map(len.map(|len| len + 1)));
+ tri!(map.serialize_entry(self.tag, self.variant_name));
Ok(map)
}
@@ -290,8 +290,8 @@ where
name: &'static str,
len: usize,
) -> Result<Self::SerializeStruct, Self::Error> {
- let mut state = try!(self.delegate.serialize_struct(name, len + 1));
- try!(state.serialize_field(self.tag, self.variant_name));
+ let mut state = tri!(self.delegate.serialize_struct(name, len + 1));
+ tri!(state.serialize_field(self.tag, self.variant_name));
Ok(state)
}
@@ -316,9 +316,9 @@ where
inner_variant: &'static str,
len: usize,
) -> Result<Self::SerializeStructVariant, Self::Error> {
- let mut map = try!(self.delegate.serialize_map(Some(2)));
- try!(map.serialize_entry(self.tag, self.variant_name));
- try!(map.serialize_key(inner_variant));
+ let mut map = tri!(self.delegate.serialize_map(Some(2)));
+ tri!(map.serialize_entry(self.tag, self.variant_name));
+ tri!(map.serialize_key(inner_variant));
Ok(SerializeStructVariantAsMapValue::new(
map,
inner_variant,
@@ -337,9 +337,9 @@ where
#[cfg(any(feature = "std", feature = "alloc"))]
mod content {
- use lib::*;
+ use crate::lib::*;
- use ser::{self, Serialize, Serializer};
+ use crate::ser::{self, Serialize, Serializer};
pub struct SerializeTupleVariantAsMapValue<M> {
map: M,
@@ -368,13 +368,13 @@ mod content {
where
T: Serialize,
{
- let value = try!(value.serialize(ContentSerializer::<M::Error>::new()));
+ let value = tri!(value.serialize(ContentSerializer::<M::Error>::new()));
self.fields.push(value);
Ok(())
}
fn end(mut self) -> Result<M::Ok, M::Error> {
- try!(self
+ tri!(self
.map
.serialize_value(&Content::TupleStruct(self.name, self.fields)));
self.map.end()
@@ -412,13 +412,13 @@ mod content {
where
T: Serialize,
{
- let value = try!(value.serialize(ContentSerializer::<M::Error>::new()));
+ let value = tri!(value.serialize(ContentSerializer::<M::Error>::new()));
self.fields.push((key, value));
Ok(())
}
fn end(mut self) -> Result<M::Ok, M::Error> {
- try!(self
+ tri!(self
.map
.serialize_value(&Content::Struct(self.name, self.fields)));
self.map.end()
@@ -499,50 +499,50 @@ mod content {
}
Content::Seq(ref elements) => elements.serialize(serializer),
Content::Tuple(ref elements) => {
- use ser::SerializeTuple;
- let mut tuple = try!(serializer.serialize_tuple(elements.len()));
+ use crate::ser::SerializeTuple;
+ let mut tuple = tri!(serializer.serialize_tuple(elements.len()));
for e in elements {
- try!(tuple.serialize_element(e));
+ tri!(tuple.serialize_element(e));
}
tuple.end()
}
Content::TupleStruct(n, ref fields) => {
- use ser::SerializeTupleStruct;
- let mut ts = try!(serializer.serialize_tuple_struct(n, fields.len()));
+ use crate::ser::SerializeTupleStruct;
+ let mut ts = tri!(serializer.serialize_tuple_struct(n, fields.len()));
for f in fields {
- try!(ts.serialize_field(f));
+ tri!(ts.serialize_field(f));
}
ts.end()
}
Content::TupleVariant(n, i, v, ref fields) => {
- use ser::SerializeTupleVariant;
- let mut tv = try!(serializer.serialize_tuple_variant(n, i, v, fields.len()));
+ use crate::ser::SerializeTupleVariant;
+ let mut tv = tri!(serializer.serialize_tuple_variant(n, i, v, fields.len()));
for f in fields {
- try!(tv.serialize_field(f));
+ tri!(tv.serialize_field(f));
}
tv.end()
}
Content::Map(ref entries) => {
- use ser::SerializeMap;
- let mut map = try!(serializer.serialize_map(Some(entries.len())));
+ use crate::ser::SerializeMap;
+ let mut map = tri!(serializer.serialize_map(Some(entries.len())));
for (k, v) in entries {
- try!(map.serialize_entry(k, v));
+ tri!(map.serialize_entry(k, v));
}
map.end()
}
Content::Struct(n, ref fields) => {
- use ser::SerializeStruct;
- let mut s = try!(serializer.serialize_struct(n, fields.len()));
+ use crate::ser::SerializeStruct;
+ let mut s = tri!(serializer.serialize_struct(n, fields.len()));
for &(k, ref v) in fields {
- try!(s.serialize_field(k, v));
+ tri!(s.serialize_field(k, v));
}
s.end()
}
Content::StructVariant(n, i, v, ref fields) => {
- use ser::SerializeStructVariant;
- let mut sv = try!(serializer.serialize_struct_variant(n, i, v, fields.len()));
+ use crate::ser::SerializeStructVariant;
+ let mut sv = tri!(serializer.serialize_struct_variant(n, i, v, fields.len()));
for &(k, ref v) in fields {
- try!(sv.serialize_field(k, v));
+ tri!(sv.serialize_field(k, v));
}
sv.end()
}
@@ -639,7 +639,7 @@ mod content {
where
T: Serialize,
{
- Ok(Content::Some(Box::new(try!(value.serialize(self)))))
+ Ok(Content::Some(Box::new(tri!(value.serialize(self)))))
}
fn serialize_unit(self) -> Result<Content, E> {
@@ -669,7 +669,7 @@ mod content {
{
Ok(Content::NewtypeStruct(
name,
- Box::new(try!(value.serialize(self))),
+ Box::new(tri!(value.serialize(self))),
))
}
@@ -687,7 +687,7 @@ mod content {
name,
variant_index,
variant,
- Box::new(try!(value.serialize(self))),
+ Box::new(tri!(value.serialize(self))),
))
}
@@ -786,7 +786,7 @@ mod content {
where
T: Serialize,
{
- let value = try!(value.serialize(ContentSerializer::<E>::new()));
+ let value = tri!(value.serialize(ContentSerializer::<E>::new()));
self.elements.push(value);
Ok(())
}
@@ -812,7 +812,7 @@ mod content {
where
T: Serialize,
{
- let value = try!(value.serialize(ContentSerializer::<E>::new()));
+ let value = tri!(value.serialize(ContentSerializer::<E>::new()));
self.elements.push(value);
Ok(())
}
@@ -839,7 +839,7 @@ mod content {
where
T: Serialize,
{
- let value = try!(value.serialize(ContentSerializer::<E>::new()));
+ let value = tri!(value.serialize(ContentSerializer::<E>::new()));
self.fields.push(value);
Ok(())
}
@@ -868,7 +868,7 @@ mod content {
where
T: Serialize,
{
- let value = try!(value.serialize(ContentSerializer::<E>::new()));
+ let value = tri!(value.serialize(ContentSerializer::<E>::new()));
self.fields.push(value);
Ok(())
}
@@ -900,7 +900,7 @@ mod content {
where
T: Serialize,
{
- let key = try!(key.serialize(ContentSerializer::<E>::new()));
+ let key = tri!(key.serialize(ContentSerializer::<E>::new()));
self.key = Some(key);
Ok(())
}
@@ -913,7 +913,7 @@ mod content {
.key
.take()
.expect("serialize_value called before serialize_key");
- let value = try!(value.serialize(ContentSerializer::<E>::new()));
+ let value = tri!(value.serialize(ContentSerializer::<E>::new()));
self.entries.push((key, value));
Ok(())
}
@@ -927,8 +927,8 @@ mod content {
K: Serialize,
V: Serialize,
{
- let key = try!(key.serialize(ContentSerializer::<E>::new()));
- let value = try!(value.serialize(ContentSerializer::<E>::new()));
+ let key = tri!(key.serialize(ContentSerializer::<E>::new()));
+ let value = tri!(value.serialize(ContentSerializer::<E>::new()));
self.entries.push((key, value));
Ok(())
}
@@ -951,7 +951,7 @@ mod content {
where
T: Serialize,
{
- let value = try!(value.serialize(ContentSerializer::<E>::new()));
+ let value = tri!(value.serialize(ContentSerializer::<E>::new()));
self.fields.push((key, value));
Ok(())
}
@@ -980,7 +980,7 @@ mod content {
where
T: Serialize,
{
- let value = try!(value.serialize(ContentSerializer::<E>::new()));
+ let value = tri!(value.serialize(ContentSerializer::<E>::new()));
self.fields.push((key, value));
Ok(())
}
@@ -1025,7 +1025,7 @@ where
type SerializeTupleStruct = Impossible<Self::Ok, M::Error>;
type SerializeMap = FlatMapSerializeMap<'a, M>;
type SerializeStruct = FlatMapSerializeStruct<'a, M>;
- type SerializeTupleVariant = Impossible<Self::Ok, M::Error>;
+ type SerializeTupleVariant = FlatMapSerializeTupleVariantAsMapValue<'a, M>;
type SerializeStructVariant = FlatMapSerializeStructVariantAsMapValue<'a, M>;
fn serialize_bool(self, _: bool) -> Result<Self::Ok, Self::Error> {
@@ -1133,7 +1133,7 @@ where
where
T: Serialize,
{
- try!(self.0.serialize_key(variant));
+ tri!(self.0.serialize_key(variant));
self.0.serialize_value(value)
}
@@ -1157,10 +1157,11 @@ where
self,
_: &'static str,
_: u32,
- _: &'static str,
+ variant: &'static str,
_: usize,
) -> Result<Self::SerializeTupleVariant, Self::Error> {
- Err(Self::bad_type(Unsupported::Enum))
+ tri!(self.0.serialize_key(variant));
+ Ok(FlatMapSerializeTupleVariantAsMapValue::new(self.0))
}
fn serialize_map(self, _: Option<usize>) -> Result<Self::SerializeMap, Self::Error> {
@@ -1182,7 +1183,7 @@ where
inner_variant: &'static str,
_: usize,
) -> Result<Self::SerializeStructVariant, Self::Error> {
- try!(self.0.serialize_key(inner_variant));
+ tri!(self.0.serialize_key(inner_variant));
Ok(FlatMapSerializeStructVariantAsMapValue::new(
self.0,
inner_variant,
@@ -1259,6 +1260,52 @@ where
}
}
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+#[cfg(any(feature = "std", feature = "alloc"))]
+pub struct FlatMapSerializeTupleVariantAsMapValue<'a, M: 'a> {
+ map: &'a mut M,
+ fields: Vec<Content>,
+}
+
+#[cfg(any(feature = "std", feature = "alloc"))]
+impl<'a, M> FlatMapSerializeTupleVariantAsMapValue<'a, M>
+where
+ M: SerializeMap + 'a,
+{
+ fn new(map: &'a mut M) -> Self {
+ FlatMapSerializeTupleVariantAsMapValue {
+ map,
+ fields: Vec::new(),
+ }
+ }
+}
+
+#[cfg(any(feature = "std", feature = "alloc"))]
+impl<'a, M> ser::SerializeTupleVariant for FlatMapSerializeTupleVariantAsMapValue<'a, M>
+where
+ M: SerializeMap + 'a,
+{
+ type Ok = ();
+ type Error = M::Error;
+
+ fn serialize_field<T: ?Sized>(&mut self, value: &T) -> Result<(), Self::Error>
+ where
+ T: Serialize,
+ {
+ let value = tri!(value.serialize(ContentSerializer::<M::Error>::new()));
+ self.fields.push(value);
+ Ok(())
+ }
+
+ fn end(self) -> Result<(), Self::Error> {
+ tri!(self.map.serialize_value(&Content::Seq(self.fields)));
+ Ok(())
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
#[cfg(any(feature = "std", feature = "alloc"))]
pub struct FlatMapSerializeStructVariantAsMapValue<'a, M: 'a> {
map: &'a mut M,
@@ -1296,15 +1343,43 @@ where
where
T: Serialize,
{
- let value = try!(value.serialize(ContentSerializer::<M::Error>::new()));
+ let value = tri!(value.serialize(ContentSerializer::<M::Error>::new()));
self.fields.push((key, value));
Ok(())
}
fn end(self) -> Result<(), Self::Error> {
- try!(self
+ tri!(self
.map
.serialize_value(&Content::Struct(self.name, self.fields)));
Ok(())
}
}
+
+pub struct AdjacentlyTaggedEnumVariant {
+ pub enum_name: &'static str,
+ pub variant_index: u32,
+ pub variant_name: &'static str,
+}
+
+impl Serialize for AdjacentlyTaggedEnumVariant {
+ fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
+ where
+ S: Serializer,
+ {
+ serializer.serialize_unit_variant(self.enum_name, self.variant_index, self.variant_name)
+ }
+}
+
+// Error when Serialize for a non_exhaustive remote enum encounters a variant
+// that is not recognized.
+pub struct CannotSerializeVariant<T>(pub T);
+
+impl<T> Display for CannotSerializeVariant<T>
+where
+ T: Debug,
+{
+ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
+ write!(formatter, "enum variant cannot be serialized: {:?}", self.0)
+ }
+}
diff --git a/vendor/serde/src/ser/fmt.rs b/vendor/serde/src/ser/fmt.rs
index ce2d05ca8..0650ab6f1 100644
--- a/vendor/serde/src/ser/fmt.rs
+++ b/vendor/serde/src/ser/fmt.rs
@@ -1,5 +1,5 @@
-use lib::*;
-use ser::{Error, Impossible, Serialize, Serializer};
+use crate::lib::*;
+use crate::ser::{Error, Impossible, Serialize, Serializer};
impl Error for fmt::Error {
fn custom<T: Display>(_msg: T) -> Self {
@@ -52,10 +52,12 @@ impl<'a, 'b> Serializer for &'a mut fmt::Formatter<'b> {
serialize_i16: i16,
serialize_i32: i32,
serialize_i64: i64,
+ serialize_i128: i128,
serialize_u8: u8,
serialize_u16: u16,
serialize_u32: u32,
serialize_u64: u64,
+ serialize_u128: u128,
serialize_f32: f32,
serialize_f64: f64,
serialize_char: char,
@@ -63,13 +65,6 @@ impl<'a, 'b> Serializer for &'a mut fmt::Formatter<'b> {
serialize_unit_struct: &'static str,
}
- serde_if_integer128! {
- fmt_primitives! {
- serialize_i128: i128,
- serialize_u128: u128,
- }
- }
-
fn serialize_unit_variant(
self,
_name: &'static str,
diff --git a/vendor/serde/src/ser/impls.rs b/vendor/serde/src/ser/impls.rs
index 9cafb3264..39acba315 100644
--- a/vendor/serde/src/ser/impls.rs
+++ b/vendor/serde/src/ser/impls.rs
@@ -1,6 +1,6 @@
-use lib::*;
+use crate::lib::*;
-use ser::{Error, Serialize, SerializeTuple, Serializer};
+use crate::ser::{Error, Serialize, SerializeTuple, Serializer};
////////////////////////////////////////////////////////////////////////////////
@@ -24,20 +24,17 @@ primitive_impl!(i8, serialize_i8);
primitive_impl!(i16, serialize_i16);
primitive_impl!(i32, serialize_i32);
primitive_impl!(i64, serialize_i64);
+primitive_impl!(i128, serialize_i128);
primitive_impl!(usize, serialize_u64 as u64);
primitive_impl!(u8, serialize_u8);
primitive_impl!(u16, serialize_u16);
primitive_impl!(u32, serialize_u32);
primitive_impl!(u64, serialize_u64);
+primitive_impl!(u128, serialize_u128);
primitive_impl!(f32, serialize_f32);
primitive_impl!(f64, serialize_f64);
primitive_impl!(char, serialize_char);
-serde_if_integer128! {
- primitive_impl!(i128, serialize_i128);
- primitive_impl!(u128, serialize_u128);
-}
-
////////////////////////////////////////////////////////////////////////////////
impl Serialize for str {
@@ -133,7 +130,7 @@ impl<T> Serialize for [T; 0] {
where
S: Serializer,
{
- try!(serializer.serialize_tuple(0)).end()
+ tri!(serializer.serialize_tuple(0)).end()
}
}
@@ -149,9 +146,9 @@ macro_rules! array_impls {
where
S: Serializer,
{
- let mut seq = try!(serializer.serialize_tuple($len));
+ let mut seq = tri!(serializer.serialize_tuple($len));
for e in self {
- try!(seq.serialize_element(e));
+ tri!(seq.serialize_element(e));
}
seq.end()
}
@@ -248,9 +245,9 @@ where
S: Serializer,
{
use super::SerializeStruct;
- let mut state = try!(serializer.serialize_struct("Range", 2));
- try!(state.serialize_field("start", &self.start));
- try!(state.serialize_field("end", &self.end));
+ let mut state = tri!(serializer.serialize_struct("Range", 2));
+ tri!(state.serialize_field("start", &self.start));
+ tri!(state.serialize_field("end", &self.end));
state.end()
}
}
@@ -266,15 +263,14 @@ where
S: Serializer,
{
use super::SerializeStruct;
- let mut state = try!(serializer.serialize_struct("RangeFrom", 1));
- try!(state.serialize_field("start", &self.start));
+ let mut state = tri!(serializer.serialize_struct("RangeFrom", 1));
+ tri!(state.serialize_field("start", &self.start));
state.end()
}
}
////////////////////////////////////////////////////////////////////////////////
-#[cfg(not(no_range_inclusive))]
impl<Idx> Serialize for RangeInclusive<Idx>
where
Idx: Serialize,
@@ -284,9 +280,9 @@ where
S: Serializer,
{
use super::SerializeStruct;
- let mut state = try!(serializer.serialize_struct("RangeInclusive", 2));
- try!(state.serialize_field("start", &self.start()));
- try!(state.serialize_field("end", &self.end()));
+ let mut state = tri!(serializer.serialize_struct("RangeInclusive", 2));
+ tri!(state.serialize_field("start", &self.start()));
+ tri!(state.serialize_field("end", &self.end()));
state.end()
}
}
@@ -302,15 +298,14 @@ where
S: Serializer,
{
use super::SerializeStruct;
- let mut state = try!(serializer.serialize_struct("RangeTo", 1));
- try!(state.serialize_field("end", &self.end));
+ let mut state = tri!(serializer.serialize_struct("RangeTo", 1));
+ tri!(state.serialize_field("end", &self.end));
state.end()
}
}
////////////////////////////////////////////////////////////////////////////////
-#[cfg(any(not(no_ops_bound), all(feature = "std", not(no_collections_bound))))]
impl<T> Serialize for Bound<T>
where
T: Serialize,
@@ -367,9 +362,9 @@ macro_rules! tuple_impls {
where
S: Serializer,
{
- let mut tuple = try!(serializer.serialize_tuple($len));
+ let mut tuple = tri!(serializer.serialize_tuple($len));
$(
- try!(tuple.serialize_element(&self.$n));
+ tri!(tuple.serialize_element(&self.$n));
)+
tuple.end()
}
@@ -538,7 +533,6 @@ where
macro_rules! nonzero_integers {
($($T:ident,)+) => {
$(
- #[cfg(not(no_num_nonzero))]
impl Serialize for num::$T {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
@@ -556,6 +550,7 @@ nonzero_integers! {
NonZeroU16,
NonZeroU32,
NonZeroU64,
+ NonZeroU128,
NonZeroUsize,
}
@@ -565,22 +560,10 @@ nonzero_integers! {
NonZeroI16,
NonZeroI32,
NonZeroI64,
+ NonZeroI128,
NonZeroIsize,
}
-// Currently 128-bit integers do not work on Emscripten targets so we need an
-// additional `#[cfg]`
-serde_if_integer128! {
- nonzero_integers! {
- NonZeroU128,
- }
-
- #[cfg(not(no_num_nonzero_signed))]
- nonzero_integers! {
- NonZeroI128,
- }
-}
-
impl<T> Serialize for Cell<T>
where
T: Serialize + Copy,
@@ -662,16 +645,15 @@ where
////////////////////////////////////////////////////////////////////////////////
-#[cfg(any(feature = "std", not(no_core_duration)))]
impl Serialize for Duration {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
use super::SerializeStruct;
- let mut state = try!(serializer.serialize_struct("Duration", 2));
- try!(state.serialize_field("secs", &self.as_secs()));
- try!(state.serialize_field("nanos", &self.subsec_nanos()));
+ let mut state = tri!(serializer.serialize_struct("Duration", 2));
+ tri!(state.serialize_field("secs", &self.as_secs()));
+ tri!(state.serialize_field("nanos", &self.subsec_nanos()));
state.end()
}
}
@@ -689,9 +671,9 @@ impl Serialize for SystemTime {
Ok(duration_since_epoch) => duration_since_epoch,
Err(_) => return Err(S::Error::custom("SystemTime must be later than UNIX_EPOCH")),
};
- let mut state = try!(serializer.serialize_struct("SystemTime", 2));
- try!(state.serialize_field("secs_since_epoch", &duration_since_epoch.as_secs()));
- try!(state.serialize_field("nanos_since_epoch", &duration_since_epoch.subsec_nanos()));
+ let mut state = tri!(serializer.serialize_struct("SystemTime", 2));
+ tri!(state.serialize_field("secs_since_epoch", &duration_since_epoch.as_secs()));
+ tri!(state.serialize_field("nanos_since_epoch", &duration_since_epoch.subsec_nanos()));
state.end()
}
}
@@ -963,7 +945,6 @@ where
}
}
-#[cfg(not(no_core_reverse))]
impl<T> Serialize for Reverse<T>
where
T: Serialize,
diff --git a/vendor/serde/src/ser/impossible.rs b/vendor/serde/src/ser/impossible.rs
index 1d1d7ac84..479be9407 100644
--- a/vendor/serde/src/ser/impossible.rs
+++ b/vendor/serde/src/ser/impossible.rs
@@ -1,8 +1,8 @@
//! This module contains `Impossible` serializer and its implementations.
-use lib::*;
+use crate::lib::*;
-use ser::{
+use crate::ser::{
self, Serialize, SerializeMap, SerializeSeq, SerializeStruct, SerializeStructVariant,
SerializeTuple, SerializeTupleStruct, SerializeTupleVariant,
};
diff --git a/vendor/serde/src/ser/mod.rs b/vendor/serde/src/ser/mod.rs
index e1f38444d..f1820c20a 100644
--- a/vendor/serde/src/ser/mod.rs
+++ b/vendor/serde/src/ser/mod.rs
@@ -107,7 +107,7 @@
//! [derive section of the manual]: https://serde.rs/derive.html
//! [data formats]: https://serde.rs/#data-formats
-use lib::*;
+use crate::lib::*;
mod fmt;
mod impls;
@@ -115,15 +115,15 @@ mod impossible;
pub use self::impossible::Impossible;
+#[cfg(not(any(feature = "std", feature = "unstable")))]
+#[doc(no_inline)]
+pub use crate::std_error::Error as StdError;
#[cfg(all(feature = "unstable", not(feature = "std")))]
-#[doc(inline)]
+#[doc(no_inline)]
pub use core::error::Error as StdError;
#[cfg(feature = "std")]
#[doc(no_inline)]
pub use std::error::Error as StdError;
-#[cfg(not(any(feature = "std", feature = "unstable")))]
-#[doc(no_inline)]
-pub use std_error::Error as StdError;
////////////////////////////////////////////////////////////////////////////////
@@ -488,30 +488,27 @@ pub trait Serializer: Sized {
/// ```
fn serialize_i64(self, v: i64) -> Result<Self::Ok, Self::Error>;
- serde_if_integer128! {
- /// Serialize an `i128` value.
- ///
- /// ```edition2021
- /// # use serde::Serializer;
- /// #
- /// # serde::__private_serialize!();
- /// #
- /// impl Serialize for i128 {
- /// fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
- /// where
- /// S: Serializer,
- /// {
- /// serializer.serialize_i128(*self)
- /// }
- /// }
- /// ```
- ///
- /// This method is available only on Rust compiler versions >=1.26. The
- /// default behavior unconditionally returns an error.
- fn serialize_i128(self, v: i128) -> Result<Self::Ok, Self::Error> {
- let _ = v;
- Err(Error::custom("i128 is not supported"))
- }
+ /// Serialize an `i128` value.
+ ///
+ /// ```edition2021
+ /// # use serde::Serializer;
+ /// #
+ /// # serde::__private_serialize!();
+ /// #
+ /// impl Serialize for i128 {
+ /// fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
+ /// where
+ /// S: Serializer,
+ /// {
+ /// serializer.serialize_i128(*self)
+ /// }
+ /// }
+ /// ```
+ ///
+ /// The default behavior unconditionally returns an error.
+ fn serialize_i128(self, v: i128) -> Result<Self::Ok, Self::Error> {
+ let _ = v;
+ Err(Error::custom("i128 is not supported"))
}
/// Serialize a `u8` value.
@@ -598,30 +595,27 @@ pub trait Serializer: Sized {
/// ```
fn serialize_u64(self, v: u64) -> Result<Self::Ok, Self::Error>;
- serde_if_integer128! {
- /// Serialize a `u128` value.
- ///
- /// ```edition2021
- /// # use serde::Serializer;
- /// #
- /// # serde::__private_serialize!();
- /// #
- /// impl Serialize for u128 {
- /// fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
- /// where
- /// S: Serializer,
- /// {
- /// serializer.serialize_u128(*self)
- /// }
- /// }
- /// ```
- ///
- /// This method is available only on Rust compiler versions >=1.26. The
- /// default behavior unconditionally returns an error.
- fn serialize_u128(self, v: u128) -> Result<Self::Ok, Self::Error> {
- let _ = v;
- Err(Error::custom("u128 is not supported"))
- }
+ /// Serialize a `u128` value.
+ ///
+ /// ```edition2021
+ /// # use serde::Serializer;
+ /// #
+ /// # serde::__private_serialize!();
+ /// #
+ /// impl Serialize for u128 {
+ /// fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
+ /// where
+ /// S: Serializer,
+ /// {
+ /// serializer.serialize_u128(*self)
+ /// }
+ /// }
+ /// ```
+ ///
+ /// The default behavior unconditionally returns an error.
+ fn serialize_u128(self, v: u128) -> Result<Self::Ok, Self::Error> {
+ let _ = v;
+ Err(Error::custom("u128 is not supported"))
}
/// Serialize an `f32` value.
@@ -1279,22 +1273,9 @@ pub trait Serializer: Sized {
I: IntoIterator,
<I as IntoIterator>::Item: Serialize,
{
- let iter = iter.into_iter();
- let mut serializer = try!(self.serialize_seq(iterator_len_hint(&iter)));
-
- #[cfg(not(no_iterator_try_fold))]
- {
- let mut iter = iter;
- try!(iter.try_for_each(|item| serializer.serialize_element(&item)));
- }
-
- #[cfg(no_iterator_try_fold)]
- {
- for item in iter {
- try!(serializer.serialize_element(&item));
- }
- }
-
+ let mut iter = iter.into_iter();
+ let mut serializer = tri!(self.serialize_seq(iterator_len_hint(&iter)));
+ tri!(iter.try_for_each(|item| serializer.serialize_element(&item)));
serializer.end()
}
@@ -1330,22 +1311,9 @@ pub trait Serializer: Sized {
V: Serialize,
I: IntoIterator<Item = (K, V)>,
{
- let iter = iter.into_iter();
- let mut serializer = try!(self.serialize_map(iterator_len_hint(&iter)));
-
- #[cfg(not(no_iterator_try_fold))]
- {
- let mut iter = iter;
- try!(iter.try_for_each(|(key, value)| serializer.serialize_entry(&key, &value)));
- }
-
- #[cfg(no_iterator_try_fold)]
- {
- for (key, value) in iter {
- try!(serializer.serialize_entry(&key, &value));
- }
- }
-
+ let mut iter = iter.into_iter();
+ let mut serializer = tri!(self.serialize_map(iterator_len_hint(&iter)));
+ tri!(iter.try_for_each(|(key, value)| serializer.serialize_entry(&key, &value)));
serializer.end()
}
@@ -1839,7 +1807,7 @@ pub trait SerializeMap {
K: Serialize,
V: Serialize,
{
- try!(self.serialize_key(key));
+ tri!(self.serialize_key(key));
self.serialize_value(value)
}
diff --git a/vendor/serde/src/std_error.rs b/vendor/serde/src/std_error.rs
index fca023d16..f15a4d74a 100644
--- a/vendor/serde/src/std_error.rs
+++ b/vendor/serde/src/std_error.rs
@@ -1,4 +1,4 @@
-use lib::{Debug, Display};
+use crate::lib::{Debug, Display};
/// Either a re-export of std::error::Error or a new identical trait, depending
/// on whether Serde's "std" feature is enabled.