mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-04-28 23:07:55 +00:00
Compare commits
22 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 1d7899d671 | |||
| 97168d3a24 | |||
| 373b11dda7 | |||
| 69072f2423 | |||
| 5b37e8a531 | |||
| b47f4dfa96 | |||
| cbe98a9888 | |||
| 957996f5fb | |||
| 169988206a | |||
| 840f6ec9b8 | |||
| bf9ebea392 | |||
| 6c316d7cb5 | |||
| a4ac0c2bc6 | |||
| ed76364f87 | |||
| 57e21a1afa | |||
| bb58726133 | |||
| 3f6925125b | |||
| fd4decf2fe | |||
| 00b1b6b2b5 | |||
| cf141aa8c7 | |||
| 106da4905f | |||
| ae38b27aee |
@@ -11,6 +11,7 @@ resolver = "2"
|
|||||||
[patch.crates-io]
|
[patch.crates-io]
|
||||||
serde = { path = "serde" }
|
serde = { path = "serde" }
|
||||||
serde_core = { path = "serde_core" }
|
serde_core = { path = "serde_core" }
|
||||||
|
serde_derive = { path = "serde_derive" }
|
||||||
|
|
||||||
[workspace.dependencies]
|
[workspace.dependencies]
|
||||||
proc-macro2 = { version = "1.0.74", default-features = false }
|
proc-macro2 = { version = "1.0.74", default-features = false }
|
||||||
|
|||||||
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "serde"
|
name = "serde"
|
||||||
version = "1.0.221"
|
version = "1.0.225"
|
||||||
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>", "David Tolnay <dtolnay@gmail.com>"]
|
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>", "David Tolnay <dtolnay@gmail.com>"]
|
||||||
build = "build.rs"
|
build = "build.rs"
|
||||||
categories = ["encoding", "no-std", "no-std::no-alloc"]
|
categories = ["encoding", "no-std", "no-std::no-alloc"]
|
||||||
@@ -15,7 +15,7 @@ repository = "https://github.com/serde-rs/serde"
|
|||||||
rust-version = "1.56"
|
rust-version = "1.56"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
serde_core = { version = "=1.0.221", path = "../serde_core", default-features = false, features = ["result"] }
|
serde_core = { version = "=1.0.225", path = "../serde_core", default-features = false, features = ["result"] }
|
||||||
serde_derive = { version = "1", optional = true, path = "../serde_derive" }
|
serde_derive = { version = "1", optional = true, path = "../serde_derive" }
|
||||||
|
|
||||||
[package.metadata.playground]
|
[package.metadata.playground]
|
||||||
|
|||||||
@@ -1,19 +1,36 @@
|
|||||||
use std::env;
|
use std::env;
|
||||||
|
use std::fs;
|
||||||
|
use std::path::PathBuf;
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
use std::str;
|
use std::str;
|
||||||
|
|
||||||
|
const PRIVATE: &str = "\
|
||||||
|
#[doc(hidden)]
|
||||||
|
pub mod __private$$ {
|
||||||
|
#[doc(hidden)]
|
||||||
|
pub use crate::private::*;
|
||||||
|
}
|
||||||
|
use serde_core::__private$$ as serde_core_private;
|
||||||
|
";
|
||||||
|
|
||||||
// The rustc-cfg strings below are *not* public API. Please let us know by
|
// The rustc-cfg strings below are *not* public API. Please let us know by
|
||||||
// opening a GitHub issue if your build environment requires some way to enable
|
// opening a GitHub issue if your build environment requires some way to enable
|
||||||
// these cfgs other than by executing our build script.
|
// these cfgs other than by executing our build script.
|
||||||
fn main() {
|
fn main() {
|
||||||
println!("cargo:rerun-if-changed=build.rs");
|
println!("cargo:rerun-if-changed=build.rs");
|
||||||
|
|
||||||
|
let out_dir = PathBuf::from(env::var_os("OUT_DIR").unwrap());
|
||||||
|
let patch_version = env::var("CARGO_PKG_VERSION_PATCH").unwrap();
|
||||||
|
let module = PRIVATE.replace("$$", &patch_version);
|
||||||
|
fs::write(out_dir.join("private.rs"), module).unwrap();
|
||||||
|
|
||||||
let minor = match rustc_minor_version() {
|
let minor = match rustc_minor_version() {
|
||||||
Some(minor) => minor,
|
Some(minor) => minor,
|
||||||
None => return,
|
None => return,
|
||||||
};
|
};
|
||||||
|
|
||||||
if minor >= 77 {
|
if minor >= 77 {
|
||||||
|
println!("cargo:rustc-check-cfg=cfg(no_diagnostic_namespace)");
|
||||||
println!("cargo:rustc-check-cfg=cfg(no_serde_derive)");
|
println!("cargo:rustc-check-cfg=cfg(no_serde_derive)");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -21,6 +38,12 @@ fn main() {
|
|||||||
if minor < 61 {
|
if minor < 61 {
|
||||||
println!("cargo:rustc-cfg=no_serde_derive");
|
println!("cargo:rustc-cfg=no_serde_derive");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Support for the `#[diagnostic]` tool attribute namespace
|
||||||
|
// https://blog.rust-lang.org/2024/05/02/Rust-1.78.0.html#diagnostic-attributes
|
||||||
|
if minor < 78 {
|
||||||
|
println!("cargo:rustc-cfg=no_diagnostic_namespace");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn rustc_minor_version() -> Option<u32> {
|
fn rustc_minor_version() -> Option<u32> {
|
||||||
|
|||||||
+4
-3
@@ -95,7 +95,7 @@
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
// Serde types in rustdoc of other crates get linked to here.
|
// Serde types in rustdoc of other crates get linked to here.
|
||||||
#![doc(html_root_url = "https://docs.rs/serde/1.0.221")]
|
#![doc(html_root_url = "https://docs.rs/serde/1.0.225")]
|
||||||
// Support using Serde without the standard library!
|
// Support using Serde without the standard library!
|
||||||
#![cfg_attr(not(feature = "std"), no_std)]
|
#![cfg_attr(not(feature = "std"), no_std)]
|
||||||
// Show which crate feature enables conditionally compiled APIs in documentation.
|
// Show which crate feature enables conditionally compiled APIs in documentation.
|
||||||
@@ -239,8 +239,9 @@ mod integer128;
|
|||||||
|
|
||||||
// Used by generated code and doc tests. Not public API.
|
// Used by generated code and doc tests. Not public API.
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
#[path = "private/mod.rs"]
|
mod private;
|
||||||
pub mod __private;
|
|
||||||
|
include!(concat!(env!("OUT_DIR"), "/private.rs"));
|
||||||
|
|
||||||
// Re-export #[derive(Serialize, Deserialize)].
|
// Re-export #[derive(Serialize, Deserialize)].
|
||||||
//
|
//
|
||||||
|
|||||||
+315
-11
@@ -11,12 +11,13 @@ use crate::de::{MapAccess, Unexpected};
|
|||||||
|
|
||||||
#[cfg(any(feature = "std", feature = "alloc"))]
|
#[cfg(any(feature = "std", feature = "alloc"))]
|
||||||
pub use self::content::{
|
pub use self::content::{
|
||||||
content_as_str, Content, ContentDeserializer, ContentRefDeserializer, EnumDeserializer,
|
content_as_str, Content, ContentDeserializer, ContentRefDeserializer, ContentVisitor,
|
||||||
InternallyTaggedUnitVisitor, TagContentOtherField, TagContentOtherFieldVisitor,
|
EnumDeserializer, InternallyTaggedUnitVisitor, TagContentOtherField,
|
||||||
TagOrContentField, TagOrContentFieldVisitor, TaggedContentVisitor, UntaggedUnitVisitor,
|
TagContentOtherFieldVisitor, TagOrContentField, TagOrContentFieldVisitor, TaggedContentVisitor,
|
||||||
|
UntaggedUnitVisitor,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub use serde_core::__private::InPlaceSeed;
|
pub use crate::serde_core_private::InPlaceSeed;
|
||||||
|
|
||||||
/// If the missing field is of type `Option<T>` then treat is as `None`,
|
/// If the missing field is of type `Option<T>` then treat is as `None`,
|
||||||
/// otherwise it is an error.
|
/// otherwise it is an error.
|
||||||
@@ -27,6 +28,7 @@ where
|
|||||||
{
|
{
|
||||||
struct MissingFieldDeserializer<E>(&'static str, PhantomData<E>);
|
struct MissingFieldDeserializer<E>(&'static str, PhantomData<E>);
|
||||||
|
|
||||||
|
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
|
||||||
impl<'de, E> Deserializer<'de> for MissingFieldDeserializer<E>
|
impl<'de, E> Deserializer<'de> for MissingFieldDeserializer<E>
|
||||||
where
|
where
|
||||||
E: Error,
|
E: Error,
|
||||||
@@ -66,6 +68,7 @@ where
|
|||||||
{
|
{
|
||||||
struct CowStrVisitor;
|
struct CowStrVisitor;
|
||||||
|
|
||||||
|
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
|
||||||
impl<'a> Visitor<'a> for CowStrVisitor {
|
impl<'a> Visitor<'a> for CowStrVisitor {
|
||||||
type Value = Cow<'a, str>;
|
type Value = Cow<'a, str>;
|
||||||
|
|
||||||
@@ -139,6 +142,7 @@ where
|
|||||||
{
|
{
|
||||||
struct CowBytesVisitor;
|
struct CowBytesVisitor;
|
||||||
|
|
||||||
|
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
|
||||||
impl<'a> Visitor<'a> for CowBytesVisitor {
|
impl<'a> Visitor<'a> for CowBytesVisitor {
|
||||||
type Value = Cow<'a, [u8]>;
|
type Value = Cow<'a, [u8]>;
|
||||||
|
|
||||||
@@ -212,8 +216,8 @@ mod content {
|
|||||||
self, Deserialize, DeserializeSeed, Deserializer, EnumAccess, Expected, IgnoredAny,
|
self, Deserialize, DeserializeSeed, Deserializer, EnumAccess, Expected, IgnoredAny,
|
||||||
MapAccess, SeqAccess, Unexpected, Visitor,
|
MapAccess, SeqAccess, Unexpected, Visitor,
|
||||||
};
|
};
|
||||||
pub use serde_core::__private::Content;
|
use crate::serde_core_private::size_hint;
|
||||||
use serde_core::__private::{size_hint, ContentVisitor};
|
pub use crate::serde_core_private::Content;
|
||||||
|
|
||||||
pub fn content_as_str<'a, 'de>(content: &'a Content<'de>) -> Option<&'a str> {
|
pub fn content_as_str<'a, 'de>(content: &'a Content<'de>) -> Option<&'a str> {
|
||||||
match *content {
|
match *content {
|
||||||
@@ -225,6 +229,37 @@ mod content {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn content_clone<'de>(content: &Content<'de>) -> Content<'de> {
|
||||||
|
match content {
|
||||||
|
Content::Bool(b) => Content::Bool(*b),
|
||||||
|
Content::U8(n) => Content::U8(*n),
|
||||||
|
Content::U16(n) => Content::U16(*n),
|
||||||
|
Content::U32(n) => Content::U32(*n),
|
||||||
|
Content::U64(n) => Content::U64(*n),
|
||||||
|
Content::I8(n) => Content::I8(*n),
|
||||||
|
Content::I16(n) => Content::I16(*n),
|
||||||
|
Content::I32(n) => Content::I32(*n),
|
||||||
|
Content::I64(n) => Content::I64(*n),
|
||||||
|
Content::F32(f) => Content::F32(*f),
|
||||||
|
Content::F64(f) => Content::F64(*f),
|
||||||
|
Content::Char(c) => Content::Char(*c),
|
||||||
|
Content::String(s) => Content::String(s.clone()),
|
||||||
|
Content::Str(s) => Content::Str(*s),
|
||||||
|
Content::ByteBuf(b) => Content::ByteBuf(b.clone()),
|
||||||
|
Content::Bytes(b) => Content::Bytes(b),
|
||||||
|
Content::None => Content::None,
|
||||||
|
Content::Some(content) => Content::Some(Box::new(content_clone(content))),
|
||||||
|
Content::Unit => Content::Unit,
|
||||||
|
Content::Newtype(content) => Content::Newtype(Box::new(content_clone(content))),
|
||||||
|
Content::Seq(seq) => Content::Seq(seq.iter().map(content_clone).collect()),
|
||||||
|
Content::Map(map) => Content::Map(
|
||||||
|
map.iter()
|
||||||
|
.map(|(k, v)| (content_clone(k), content_clone(v)))
|
||||||
|
.collect(),
|
||||||
|
),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[cold]
|
#[cold]
|
||||||
fn content_unexpected<'a, 'de>(content: &'a Content<'de>) -> Unexpected<'a> {
|
fn content_unexpected<'a, 'de>(content: &'a Content<'de>) -> Unexpected<'a> {
|
||||||
match *content {
|
match *content {
|
||||||
@@ -252,6 +287,230 @@ mod content {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub struct ContentVisitor<'de> {
|
||||||
|
value: PhantomData<Content<'de>>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'de> ContentVisitor<'de> {
|
||||||
|
pub fn new() -> Self {
|
||||||
|
ContentVisitor { value: PhantomData }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
|
||||||
|
impl<'de> DeserializeSeed<'de> for ContentVisitor<'de> {
|
||||||
|
type Value = Content<'de>;
|
||||||
|
|
||||||
|
fn deserialize<D>(self, deserializer: D) -> Result<Self::Value, D::Error>
|
||||||
|
where
|
||||||
|
D: Deserializer<'de>,
|
||||||
|
{
|
||||||
|
deserializer.__deserialize_content_v1(self)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
|
||||||
|
impl<'de> Visitor<'de> for ContentVisitor<'de> {
|
||||||
|
type Value = Content<'de>;
|
||||||
|
|
||||||
|
fn expecting(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||||
|
fmt.write_str("any value")
|
||||||
|
}
|
||||||
|
|
||||||
|
fn visit_bool<F>(self, value: bool) -> Result<Self::Value, F>
|
||||||
|
where
|
||||||
|
F: de::Error,
|
||||||
|
{
|
||||||
|
Ok(Content::Bool(value))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn visit_i8<F>(self, value: i8) -> Result<Self::Value, F>
|
||||||
|
where
|
||||||
|
F: de::Error,
|
||||||
|
{
|
||||||
|
Ok(Content::I8(value))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn visit_i16<F>(self, value: i16) -> Result<Self::Value, F>
|
||||||
|
where
|
||||||
|
F: de::Error,
|
||||||
|
{
|
||||||
|
Ok(Content::I16(value))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn visit_i32<F>(self, value: i32) -> Result<Self::Value, F>
|
||||||
|
where
|
||||||
|
F: de::Error,
|
||||||
|
{
|
||||||
|
Ok(Content::I32(value))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn visit_i64<F>(self, value: i64) -> Result<Self::Value, F>
|
||||||
|
where
|
||||||
|
F: de::Error,
|
||||||
|
{
|
||||||
|
Ok(Content::I64(value))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn visit_u8<F>(self, value: u8) -> Result<Self::Value, F>
|
||||||
|
where
|
||||||
|
F: de::Error,
|
||||||
|
{
|
||||||
|
Ok(Content::U8(value))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn visit_u16<F>(self, value: u16) -> Result<Self::Value, F>
|
||||||
|
where
|
||||||
|
F: de::Error,
|
||||||
|
{
|
||||||
|
Ok(Content::U16(value))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn visit_u32<F>(self, value: u32) -> Result<Self::Value, F>
|
||||||
|
where
|
||||||
|
F: de::Error,
|
||||||
|
{
|
||||||
|
Ok(Content::U32(value))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn visit_u64<F>(self, value: u64) -> Result<Self::Value, F>
|
||||||
|
where
|
||||||
|
F: de::Error,
|
||||||
|
{
|
||||||
|
Ok(Content::U64(value))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn visit_f32<F>(self, value: f32) -> Result<Self::Value, F>
|
||||||
|
where
|
||||||
|
F: de::Error,
|
||||||
|
{
|
||||||
|
Ok(Content::F32(value))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn visit_f64<F>(self, value: f64) -> Result<Self::Value, F>
|
||||||
|
where
|
||||||
|
F: de::Error,
|
||||||
|
{
|
||||||
|
Ok(Content::F64(value))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn visit_char<F>(self, value: char) -> Result<Self::Value, F>
|
||||||
|
where
|
||||||
|
F: de::Error,
|
||||||
|
{
|
||||||
|
Ok(Content::Char(value))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn visit_str<F>(self, value: &str) -> Result<Self::Value, F>
|
||||||
|
where
|
||||||
|
F: de::Error,
|
||||||
|
{
|
||||||
|
Ok(Content::String(value.into()))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn visit_borrowed_str<F>(self, value: &'de str) -> Result<Self::Value, F>
|
||||||
|
where
|
||||||
|
F: de::Error,
|
||||||
|
{
|
||||||
|
Ok(Content::Str(value))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn visit_string<F>(self, value: String) -> Result<Self::Value, F>
|
||||||
|
where
|
||||||
|
F: de::Error,
|
||||||
|
{
|
||||||
|
Ok(Content::String(value))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn visit_bytes<F>(self, value: &[u8]) -> Result<Self::Value, F>
|
||||||
|
where
|
||||||
|
F: de::Error,
|
||||||
|
{
|
||||||
|
Ok(Content::ByteBuf(value.into()))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn visit_borrowed_bytes<F>(self, value: &'de [u8]) -> Result<Self::Value, F>
|
||||||
|
where
|
||||||
|
F: de::Error,
|
||||||
|
{
|
||||||
|
Ok(Content::Bytes(value))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn visit_byte_buf<F>(self, value: Vec<u8>) -> Result<Self::Value, F>
|
||||||
|
where
|
||||||
|
F: de::Error,
|
||||||
|
{
|
||||||
|
Ok(Content::ByteBuf(value))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn visit_unit<F>(self) -> Result<Self::Value, F>
|
||||||
|
where
|
||||||
|
F: de::Error,
|
||||||
|
{
|
||||||
|
Ok(Content::Unit)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn visit_none<F>(self) -> Result<Self::Value, F>
|
||||||
|
where
|
||||||
|
F: de::Error,
|
||||||
|
{
|
||||||
|
Ok(Content::None)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn visit_some<D>(self, deserializer: D) -> Result<Self::Value, D::Error>
|
||||||
|
where
|
||||||
|
D: Deserializer<'de>,
|
||||||
|
{
|
||||||
|
let v = tri!(ContentVisitor::new().deserialize(deserializer));
|
||||||
|
Ok(Content::Some(Box::new(v)))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn visit_newtype_struct<D>(self, deserializer: D) -> Result<Self::Value, D::Error>
|
||||||
|
where
|
||||||
|
D: Deserializer<'de>,
|
||||||
|
{
|
||||||
|
let v = tri!(ContentVisitor::new().deserialize(deserializer));
|
||||||
|
Ok(Content::Newtype(Box::new(v)))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn visit_seq<V>(self, mut visitor: V) -> Result<Self::Value, V::Error>
|
||||||
|
where
|
||||||
|
V: SeqAccess<'de>,
|
||||||
|
{
|
||||||
|
let mut vec =
|
||||||
|
Vec::<Content>::with_capacity(size_hint::cautious::<Content>(visitor.size_hint()));
|
||||||
|
while let Some(e) = tri!(visitor.next_element_seed(ContentVisitor::new())) {
|
||||||
|
vec.push(e);
|
||||||
|
}
|
||||||
|
Ok(Content::Seq(vec))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn visit_map<V>(self, mut visitor: V) -> Result<Self::Value, V::Error>
|
||||||
|
where
|
||||||
|
V: MapAccess<'de>,
|
||||||
|
{
|
||||||
|
let mut vec =
|
||||||
|
Vec::<(Content, Content)>::with_capacity(
|
||||||
|
size_hint::cautious::<(Content, Content)>(visitor.size_hint()),
|
||||||
|
);
|
||||||
|
while let Some(kv) =
|
||||||
|
tri!(visitor.next_entry_seed(ContentVisitor::new(), ContentVisitor::new()))
|
||||||
|
{
|
||||||
|
vec.push(kv);
|
||||||
|
}
|
||||||
|
Ok(Content::Map(vec))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn visit_enum<V>(self, _visitor: V) -> Result<Self::Value, V::Error>
|
||||||
|
where
|
||||||
|
V: EnumAccess<'de>,
|
||||||
|
{
|
||||||
|
Err(de::Error::custom(
|
||||||
|
"untagged and internally tagged enums do not support enum input",
|
||||||
|
))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// This is the type of the map keys in an internally tagged enum.
|
/// This is the type of the map keys in an internally tagged enum.
|
||||||
///
|
///
|
||||||
/// Not public API.
|
/// Not public API.
|
||||||
@@ -276,6 +535,7 @@ mod content {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
|
||||||
impl<'de> DeserializeSeed<'de> for TagOrContentVisitor<'de> {
|
impl<'de> DeserializeSeed<'de> for TagOrContentVisitor<'de> {
|
||||||
type Value = TagOrContent<'de>;
|
type Value = TagOrContent<'de>;
|
||||||
|
|
||||||
@@ -289,6 +549,7 @@ mod content {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
|
||||||
impl<'de> Visitor<'de> for TagOrContentVisitor<'de> {
|
impl<'de> Visitor<'de> for TagOrContentVisitor<'de> {
|
||||||
type Value = TagOrContent<'de>;
|
type Value = TagOrContent<'de>;
|
||||||
|
|
||||||
@@ -570,6 +831,7 @@ mod content {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
|
||||||
impl<'de, T> Visitor<'de> for TaggedContentVisitor<T>
|
impl<'de, T> Visitor<'de> for TaggedContentVisitor<T>
|
||||||
where
|
where
|
||||||
T: Deserialize<'de>,
|
T: Deserialize<'de>,
|
||||||
@@ -591,7 +853,7 @@ mod content {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
let rest = de::value::SeqAccessDeserializer::new(seq);
|
let rest = de::value::SeqAccessDeserializer::new(seq);
|
||||||
Ok((tag, tri!(Content::deserialize(rest))))
|
Ok((tag, tri!(ContentVisitor::new().deserialize(rest))))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_map<M>(self, mut map: M) -> Result<Self::Value, M::Error>
|
fn visit_map<M>(self, mut map: M) -> Result<Self::Value, M::Error>
|
||||||
@@ -612,7 +874,7 @@ mod content {
|
|||||||
tag = Some(tri!(map.next_value()));
|
tag = Some(tri!(map.next_value()));
|
||||||
}
|
}
|
||||||
TagOrContent::Content(k) => {
|
TagOrContent::Content(k) => {
|
||||||
let v = tri!(map.next_value());
|
let v = tri!(map.next_value_seed(ContentVisitor::new()));
|
||||||
vec.push((k, v));
|
vec.push((k, v));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -640,6 +902,7 @@ mod content {
|
|||||||
pub content: &'static str,
|
pub content: &'static str,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
|
||||||
impl<'de> DeserializeSeed<'de> for TagOrContentFieldVisitor {
|
impl<'de> DeserializeSeed<'de> for TagOrContentFieldVisitor {
|
||||||
type Value = TagOrContentField;
|
type Value = TagOrContentField;
|
||||||
|
|
||||||
@@ -651,6 +914,7 @@ mod content {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
|
||||||
impl<'de> Visitor<'de> for TagOrContentFieldVisitor {
|
impl<'de> Visitor<'de> for TagOrContentFieldVisitor {
|
||||||
type Value = TagOrContentField;
|
type Value = TagOrContentField;
|
||||||
|
|
||||||
@@ -717,6 +981,7 @@ mod content {
|
|||||||
pub content: &'static str,
|
pub content: &'static str,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
|
||||||
impl<'de> DeserializeSeed<'de> for TagContentOtherFieldVisitor {
|
impl<'de> DeserializeSeed<'de> for TagContentOtherFieldVisitor {
|
||||||
type Value = TagContentOtherField;
|
type Value = TagContentOtherField;
|
||||||
|
|
||||||
@@ -728,6 +993,7 @@ mod content {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
|
||||||
impl<'de> Visitor<'de> for TagContentOtherFieldVisitor {
|
impl<'de> Visitor<'de> for TagContentOtherFieldVisitor {
|
||||||
type Value = TagContentOtherField;
|
type Value = TagContentOtherField;
|
||||||
|
|
||||||
@@ -850,6 +1116,7 @@ mod content {
|
|||||||
|
|
||||||
/// Used when deserializing an internally tagged enum because the content
|
/// Used when deserializing an internally tagged enum because the content
|
||||||
/// will be used exactly once.
|
/// will be used exactly once.
|
||||||
|
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
|
||||||
impl<'de, E> Deserializer<'de> for ContentDeserializer<'de, E>
|
impl<'de, E> Deserializer<'de> for ContentDeserializer<'de, E>
|
||||||
where
|
where
|
||||||
E: de::Error,
|
E: de::Error,
|
||||||
@@ -1269,6 +1536,7 @@ mod content {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
|
||||||
impl<'de, E> Deserializer<'de> for SeqDeserializer<'de, E>
|
impl<'de, E> Deserializer<'de> for SeqDeserializer<'de, E>
|
||||||
where
|
where
|
||||||
E: de::Error,
|
E: de::Error,
|
||||||
@@ -1291,6 +1559,7 @@ mod content {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
|
||||||
impl<'de, E> SeqAccess<'de> for SeqDeserializer<'de, E>
|
impl<'de, E> SeqAccess<'de> for SeqDeserializer<'de, E>
|
||||||
where
|
where
|
||||||
E: de::Error,
|
E: de::Error,
|
||||||
@@ -1317,6 +1586,7 @@ mod content {
|
|||||||
|
|
||||||
struct ExpectedInSeq(usize);
|
struct ExpectedInSeq(usize);
|
||||||
|
|
||||||
|
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
|
||||||
impl Expected for ExpectedInSeq {
|
impl Expected for ExpectedInSeq {
|
||||||
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
|
||||||
if self.0 == 1 {
|
if self.0 == 1 {
|
||||||
@@ -1331,7 +1601,6 @@ mod content {
|
|||||||
iter: <Vec<(Content<'de>, Content<'de>)> as IntoIterator>::IntoIter,
|
iter: <Vec<(Content<'de>, Content<'de>)> as IntoIterator>::IntoIter,
|
||||||
value: Option<Content<'de>>,
|
value: Option<Content<'de>>,
|
||||||
count: usize,
|
count: usize,
|
||||||
lifetime: PhantomData<&'de ()>,
|
|
||||||
error: PhantomData<E>,
|
error: PhantomData<E>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1341,7 +1610,6 @@ mod content {
|
|||||||
iter: content.into_iter(),
|
iter: content.into_iter(),
|
||||||
value: None,
|
value: None,
|
||||||
count: 0,
|
count: 0,
|
||||||
lifetime: PhantomData,
|
|
||||||
error: PhantomData,
|
error: PhantomData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1378,6 +1646,7 @@ mod content {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
|
||||||
impl<'de, E> Deserializer<'de> for MapDeserializer<'de, E>
|
impl<'de, E> Deserializer<'de> for MapDeserializer<'de, E>
|
||||||
where
|
where
|
||||||
E: de::Error,
|
E: de::Error,
|
||||||
@@ -1417,6 +1686,7 @@ mod content {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
|
||||||
impl<'de, E> MapAccess<'de> for MapDeserializer<'de, E>
|
impl<'de, E> MapAccess<'de> for MapDeserializer<'de, E>
|
||||||
where
|
where
|
||||||
E: de::Error,
|
E: de::Error,
|
||||||
@@ -1471,6 +1741,7 @@ mod content {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
|
||||||
impl<'de, E> SeqAccess<'de> for MapDeserializer<'de, E>
|
impl<'de, E> SeqAccess<'de> for MapDeserializer<'de, E>
|
||||||
where
|
where
|
||||||
E: de::Error,
|
E: de::Error,
|
||||||
@@ -1497,6 +1768,7 @@ mod content {
|
|||||||
|
|
||||||
struct PairDeserializer<'de, E>(Content<'de>, Content<'de>, PhantomData<E>);
|
struct PairDeserializer<'de, E>(Content<'de>, Content<'de>, PhantomData<E>);
|
||||||
|
|
||||||
|
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
|
||||||
impl<'de, E> Deserializer<'de> for PairDeserializer<'de, E>
|
impl<'de, E> Deserializer<'de> for PairDeserializer<'de, E>
|
||||||
where
|
where
|
||||||
E: de::Error,
|
E: de::Error,
|
||||||
@@ -1548,6 +1820,7 @@ mod content {
|
|||||||
|
|
||||||
struct PairVisitor<'de, E>(Option<Content<'de>>, Option<Content<'de>>, PhantomData<E>);
|
struct PairVisitor<'de, E>(Option<Content<'de>>, Option<Content<'de>>, PhantomData<E>);
|
||||||
|
|
||||||
|
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
|
||||||
impl<'de, E> SeqAccess<'de> for PairVisitor<'de, E>
|
impl<'de, E> SeqAccess<'de> for PairVisitor<'de, E>
|
||||||
where
|
where
|
||||||
E: de::Error,
|
E: de::Error,
|
||||||
@@ -1580,6 +1853,7 @@ mod content {
|
|||||||
|
|
||||||
struct ExpectedInMap(usize);
|
struct ExpectedInMap(usize);
|
||||||
|
|
||||||
|
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
|
||||||
impl Expected for ExpectedInMap {
|
impl Expected for ExpectedInMap {
|
||||||
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
|
||||||
if self.0 == 1 {
|
if self.0 == 1 {
|
||||||
@@ -1612,6 +1886,7 @@ mod content {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
|
||||||
impl<'de, E> de::EnumAccess<'de> for EnumDeserializer<'de, E>
|
impl<'de, E> de::EnumAccess<'de> for EnumDeserializer<'de, E>
|
||||||
where
|
where
|
||||||
E: de::Error,
|
E: de::Error,
|
||||||
@@ -1640,6 +1915,7 @@ mod content {
|
|||||||
err: PhantomData<E>,
|
err: PhantomData<E>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
|
||||||
impl<'de, E> de::VariantAccess<'de> for VariantDeserializer<'de, E>
|
impl<'de, E> de::VariantAccess<'de> for VariantDeserializer<'de, E>
|
||||||
where
|
where
|
||||||
E: de::Error,
|
E: de::Error,
|
||||||
@@ -1794,6 +2070,7 @@ mod content {
|
|||||||
|
|
||||||
/// Used when deserializing an untagged enum because the content may need
|
/// Used when deserializing an untagged enum because the content may need
|
||||||
/// to be used more than once.
|
/// to be used more than once.
|
||||||
|
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
|
||||||
impl<'de, 'a, E> Deserializer<'de> for ContentRefDeserializer<'a, 'de, E>
|
impl<'de, 'a, E> Deserializer<'de> for ContentRefDeserializer<'a, 'de, E>
|
||||||
where
|
where
|
||||||
E: de::Error,
|
E: de::Error,
|
||||||
@@ -2158,7 +2435,7 @@ mod content {
|
|||||||
V: Visitor<'de, Value = Content<'de>>,
|
V: Visitor<'de, Value = Content<'de>>,
|
||||||
{
|
{
|
||||||
let _ = visitor;
|
let _ = visitor;
|
||||||
Ok(self.content.clone())
|
Ok(content_clone(self.content))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2172,8 +2449,10 @@ mod content {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
|
||||||
impl<'a, 'de: 'a, E> Copy for ContentRefDeserializer<'a, 'de, E> {}
|
impl<'a, 'de: 'a, E> Copy for ContentRefDeserializer<'a, 'de, E> {}
|
||||||
|
|
||||||
|
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
|
||||||
impl<'a, 'de: 'a, E> Clone for ContentRefDeserializer<'a, 'de, E> {
|
impl<'a, 'de: 'a, E> Clone for ContentRefDeserializer<'a, 'de, E> {
|
||||||
fn clone(&self) -> Self {
|
fn clone(&self) -> Self {
|
||||||
*self
|
*self
|
||||||
@@ -2215,6 +2494,7 @@ mod content {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
|
||||||
impl<'a, 'de, E> Deserializer<'de> for SeqRefDeserializer<'a, 'de, E>
|
impl<'a, 'de, E> Deserializer<'de> for SeqRefDeserializer<'a, 'de, E>
|
||||||
where
|
where
|
||||||
E: de::Error,
|
E: de::Error,
|
||||||
@@ -2237,6 +2517,7 @@ mod content {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
|
||||||
impl<'a, 'de, E> SeqAccess<'de> for SeqRefDeserializer<'a, 'de, E>
|
impl<'a, 'de, E> SeqAccess<'de> for SeqRefDeserializer<'a, 'de, E>
|
||||||
where
|
where
|
||||||
E: de::Error,
|
E: de::Error,
|
||||||
@@ -2311,6 +2592,7 @@ mod content {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
|
||||||
impl<'a, 'de, E> Deserializer<'de> for MapRefDeserializer<'a, 'de, E>
|
impl<'a, 'de, E> Deserializer<'de> for MapRefDeserializer<'a, 'de, E>
|
||||||
where
|
where
|
||||||
E: de::Error,
|
E: de::Error,
|
||||||
@@ -2350,6 +2632,7 @@ mod content {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
|
||||||
impl<'a, 'de, E> MapAccess<'de> for MapRefDeserializer<'a, 'de, E>
|
impl<'a, 'de, E> MapAccess<'de> for MapRefDeserializer<'a, 'de, E>
|
||||||
where
|
where
|
||||||
E: de::Error,
|
E: de::Error,
|
||||||
@@ -2404,6 +2687,7 @@ mod content {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
|
||||||
impl<'a, 'de, E> SeqAccess<'de> for MapRefDeserializer<'a, 'de, E>
|
impl<'a, 'de, E> SeqAccess<'de> for MapRefDeserializer<'a, 'de, E>
|
||||||
where
|
where
|
||||||
E: de::Error,
|
E: de::Error,
|
||||||
@@ -2430,6 +2714,7 @@ mod content {
|
|||||||
|
|
||||||
struct PairRefDeserializer<'a, 'de, E>(&'a Content<'de>, &'a Content<'de>, PhantomData<E>);
|
struct PairRefDeserializer<'a, 'de, E>(&'a Content<'de>, &'a Content<'de>, PhantomData<E>);
|
||||||
|
|
||||||
|
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
|
||||||
impl<'a, 'de, E> Deserializer<'de> for PairRefDeserializer<'a, 'de, E>
|
impl<'a, 'de, E> Deserializer<'de> for PairRefDeserializer<'a, 'de, E>
|
||||||
where
|
where
|
||||||
E: de::Error,
|
E: de::Error,
|
||||||
@@ -2485,6 +2770,7 @@ mod content {
|
|||||||
PhantomData<E>,
|
PhantomData<E>,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
|
||||||
impl<'a, 'de, E> SeqAccess<'de> for PairRefVisitor<'a, 'de, E>
|
impl<'a, 'de, E> SeqAccess<'de> for PairRefVisitor<'a, 'de, E>
|
||||||
where
|
where
|
||||||
E: de::Error,
|
E: de::Error,
|
||||||
@@ -2524,6 +2810,7 @@ mod content {
|
|||||||
err: PhantomData<E>,
|
err: PhantomData<E>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
|
||||||
impl<'de, 'a, E> de::EnumAccess<'de> for EnumRefDeserializer<'a, 'de, E>
|
impl<'de, 'a, E> de::EnumAccess<'de> for EnumRefDeserializer<'a, 'de, E>
|
||||||
where
|
where
|
||||||
E: de::Error,
|
E: de::Error,
|
||||||
@@ -2552,6 +2839,7 @@ mod content {
|
|||||||
err: PhantomData<E>,
|
err: PhantomData<E>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
|
||||||
impl<'de, 'a, E> de::VariantAccess<'de> for VariantRefDeserializer<'a, 'de, E>
|
impl<'de, 'a, E> de::VariantAccess<'de> for VariantRefDeserializer<'a, 'de, E>
|
||||||
where
|
where
|
||||||
E: de::Error,
|
E: de::Error,
|
||||||
@@ -2638,6 +2926,7 @@ mod content {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
|
||||||
impl<'de, E> de::IntoDeserializer<'de, E> for ContentDeserializer<'de, E>
|
impl<'de, E> de::IntoDeserializer<'de, E> for ContentDeserializer<'de, E>
|
||||||
where
|
where
|
||||||
E: de::Error,
|
E: de::Error,
|
||||||
@@ -2649,6 +2938,7 @@ mod content {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
|
||||||
impl<'de, 'a, E> de::IntoDeserializer<'de, E> for ContentRefDeserializer<'a, 'de, E>
|
impl<'de, 'a, E> de::IntoDeserializer<'de, E> for ContentRefDeserializer<'a, 'de, E>
|
||||||
where
|
where
|
||||||
E: de::Error,
|
E: de::Error,
|
||||||
@@ -2678,6 +2968,7 @@ mod content {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
|
||||||
impl<'de, 'a> Visitor<'de> for InternallyTaggedUnitVisitor<'a> {
|
impl<'de, 'a> Visitor<'de> for InternallyTaggedUnitVisitor<'a> {
|
||||||
type Value = ();
|
type Value = ();
|
||||||
|
|
||||||
@@ -2723,6 +3014,7 @@ mod content {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
|
||||||
impl<'de, 'a> Visitor<'de> for UntaggedUnitVisitor<'a> {
|
impl<'de, 'a> Visitor<'de> for UntaggedUnitVisitor<'a> {
|
||||||
type Value = ();
|
type Value = ();
|
||||||
|
|
||||||
@@ -2770,6 +3062,7 @@ pub trait IdentifierDeserializer<'de, E: Error> {
|
|||||||
|
|
||||||
pub struct Borrowed<'de, T: 'de + ?Sized>(pub &'de T);
|
pub struct Borrowed<'de, T: 'de + ?Sized>(pub &'de T);
|
||||||
|
|
||||||
|
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
|
||||||
impl<'de, E> IdentifierDeserializer<'de, E> for u64
|
impl<'de, E> IdentifierDeserializer<'de, E> for u64
|
||||||
where
|
where
|
||||||
E: Error,
|
E: Error,
|
||||||
@@ -2786,6 +3079,7 @@ pub struct StrDeserializer<'a, E> {
|
|||||||
marker: PhantomData<E>,
|
marker: PhantomData<E>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
|
||||||
impl<'de, 'a, E> Deserializer<'de> for StrDeserializer<'a, E>
|
impl<'de, 'a, E> Deserializer<'de> for StrDeserializer<'a, E>
|
||||||
where
|
where
|
||||||
E: Error,
|
E: Error,
|
||||||
@@ -2811,6 +3105,7 @@ pub struct BorrowedStrDeserializer<'de, E> {
|
|||||||
marker: PhantomData<E>,
|
marker: PhantomData<E>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
|
||||||
impl<'de, E> Deserializer<'de> for BorrowedStrDeserializer<'de, E>
|
impl<'de, E> Deserializer<'de> for BorrowedStrDeserializer<'de, E>
|
||||||
where
|
where
|
||||||
E: Error,
|
E: Error,
|
||||||
@@ -2831,6 +3126,7 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
|
||||||
impl<'a, E> IdentifierDeserializer<'a, E> for &'a str
|
impl<'a, E> IdentifierDeserializer<'a, E> for &'a str
|
||||||
where
|
where
|
||||||
E: Error,
|
E: Error,
|
||||||
@@ -2845,6 +3141,7 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
|
||||||
impl<'de, E> IdentifierDeserializer<'de, E> for Borrowed<'de, str>
|
impl<'de, E> IdentifierDeserializer<'de, E> for Borrowed<'de, str>
|
||||||
where
|
where
|
||||||
E: Error,
|
E: Error,
|
||||||
@@ -2859,6 +3156,7 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
|
||||||
impl<'a, E> IdentifierDeserializer<'a, E> for &'a [u8]
|
impl<'a, E> IdentifierDeserializer<'a, E> for &'a [u8]
|
||||||
where
|
where
|
||||||
E: Error,
|
E: Error,
|
||||||
@@ -2870,6 +3168,7 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
|
||||||
impl<'de, E> IdentifierDeserializer<'de, E> for Borrowed<'de, [u8]>
|
impl<'de, E> IdentifierDeserializer<'de, E> for Borrowed<'de, [u8]>
|
||||||
where
|
where
|
||||||
E: Error,
|
E: Error,
|
||||||
@@ -2912,6 +3211,7 @@ macro_rules! forward_to_deserialize_other {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(feature = "std", feature = "alloc"))]
|
#[cfg(any(feature = "std", feature = "alloc"))]
|
||||||
|
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
|
||||||
impl<'a, 'de, E> Deserializer<'de> for FlatMapDeserializer<'a, 'de, E>
|
impl<'a, 'de, E> Deserializer<'de> for FlatMapDeserializer<'a, 'de, E>
|
||||||
where
|
where
|
||||||
E: Error,
|
E: Error,
|
||||||
@@ -3048,6 +3348,7 @@ struct FlatMapAccess<'a, 'de: 'a, E> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(feature = "std", feature = "alloc"))]
|
#[cfg(any(feature = "std", feature = "alloc"))]
|
||||||
|
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
|
||||||
impl<'a, 'de, E> MapAccess<'de> for FlatMapAccess<'a, 'de, E>
|
impl<'a, 'de, E> MapAccess<'de> for FlatMapAccess<'a, 'de, E>
|
||||||
where
|
where
|
||||||
E: Error,
|
E: Error,
|
||||||
@@ -3092,6 +3393,7 @@ struct FlatStructAccess<'a, 'de: 'a, E> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(feature = "std", feature = "alloc"))]
|
#[cfg(any(feature = "std", feature = "alloc"))]
|
||||||
|
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
|
||||||
impl<'a, 'de, E> MapAccess<'de> for FlatStructAccess<'a, 'de, E>
|
impl<'a, 'de, E> MapAccess<'de> for FlatStructAccess<'a, 'de, E>
|
||||||
where
|
where
|
||||||
E: Error,
|
E: Error,
|
||||||
@@ -3155,6 +3457,7 @@ pub struct AdjacentlyTaggedEnumVariantVisitor<F> {
|
|||||||
fields_enum: PhantomData<F>,
|
fields_enum: PhantomData<F>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
|
||||||
impl<'de, F> Visitor<'de> for AdjacentlyTaggedEnumVariantVisitor<F>
|
impl<'de, F> Visitor<'de> for AdjacentlyTaggedEnumVariantVisitor<F>
|
||||||
where
|
where
|
||||||
F: Deserialize<'de>,
|
F: Deserialize<'de>,
|
||||||
@@ -3175,6 +3478,7 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
|
||||||
impl<'de, F> DeserializeSeed<'de> for AdjacentlyTaggedEnumVariantSeed<F>
|
impl<'de, F> DeserializeSeed<'de> for AdjacentlyTaggedEnumVariantSeed<F>
|
||||||
where
|
where
|
||||||
F: Deserialize<'de>,
|
F: Deserialize<'de>,
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ pub use crate::lib::option::Option::{self, None, Some};
|
|||||||
pub use crate::lib::ptr;
|
pub use crate::lib::ptr;
|
||||||
pub use crate::lib::result::Result::{self, Err, Ok};
|
pub use crate::lib::result::Result::{self, Err, Ok};
|
||||||
|
|
||||||
pub use serde_core::__private::string::from_utf8_lossy;
|
pub use crate::serde_core_private::string::from_utf8_lossy;
|
||||||
|
|
||||||
#[cfg(any(feature = "alloc", feature = "std"))]
|
#[cfg(any(feature = "alloc", feature = "std"))]
|
||||||
pub use crate::lib::{ToString, Vec};
|
pub use crate::lib::{ToString, Vec};
|
||||||
|
|||||||
@@ -58,6 +58,7 @@ enum Unsupported {
|
|||||||
Enum,
|
Enum,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
|
||||||
impl Display for Unsupported {
|
impl Display for Unsupported {
|
||||||
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
|
||||||
match *self {
|
match *self {
|
||||||
@@ -89,6 +90,7 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
|
||||||
impl<S> Serializer for TaggedSerializer<S>
|
impl<S> Serializer for TaggedSerializer<S>
|
||||||
where
|
where
|
||||||
S: Serializer,
|
S: Serializer,
|
||||||
@@ -355,6 +357,7 @@ mod content {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
|
||||||
impl<M> ser::SerializeTupleVariant for SerializeTupleVariantAsMapValue<M>
|
impl<M> ser::SerializeTupleVariant for SerializeTupleVariantAsMapValue<M>
|
||||||
where
|
where
|
||||||
M: ser::SerializeMap,
|
M: ser::SerializeMap,
|
||||||
@@ -395,6 +398,7 @@ mod content {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
|
||||||
impl<M> ser::SerializeStructVariant for SerializeStructVariantAsMapValue<M>
|
impl<M> ser::SerializeStructVariant for SerializeStructVariantAsMapValue<M>
|
||||||
where
|
where
|
||||||
M: ser::SerializeMap,
|
M: ser::SerializeMap,
|
||||||
@@ -462,6 +466,7 @@ mod content {
|
|||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
|
||||||
impl Serialize for Content {
|
impl Serialize for Content {
|
||||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||||
where
|
where
|
||||||
@@ -554,6 +559,7 @@ mod content {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
|
||||||
impl<E> Serializer for ContentSerializer<E>
|
impl<E> Serializer for ContentSerializer<E>
|
||||||
where
|
where
|
||||||
E: ser::Error,
|
E: ser::Error,
|
||||||
@@ -765,6 +771,7 @@ mod content {
|
|||||||
error: PhantomData<E>,
|
error: PhantomData<E>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
|
||||||
impl<E> ser::SerializeSeq for SerializeSeq<E>
|
impl<E> ser::SerializeSeq for SerializeSeq<E>
|
||||||
where
|
where
|
||||||
E: ser::Error,
|
E: ser::Error,
|
||||||
@@ -791,6 +798,7 @@ mod content {
|
|||||||
error: PhantomData<E>,
|
error: PhantomData<E>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
|
||||||
impl<E> ser::SerializeTuple for SerializeTuple<E>
|
impl<E> ser::SerializeTuple for SerializeTuple<E>
|
||||||
where
|
where
|
||||||
E: ser::Error,
|
E: ser::Error,
|
||||||
@@ -818,6 +826,7 @@ mod content {
|
|||||||
error: PhantomData<E>,
|
error: PhantomData<E>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
|
||||||
impl<E> ser::SerializeTupleStruct for SerializeTupleStruct<E>
|
impl<E> ser::SerializeTupleStruct for SerializeTupleStruct<E>
|
||||||
where
|
where
|
||||||
E: ser::Error,
|
E: ser::Error,
|
||||||
@@ -847,6 +856,7 @@ mod content {
|
|||||||
error: PhantomData<E>,
|
error: PhantomData<E>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
|
||||||
impl<E> ser::SerializeTupleVariant for SerializeTupleVariant<E>
|
impl<E> ser::SerializeTupleVariant for SerializeTupleVariant<E>
|
||||||
where
|
where
|
||||||
E: ser::Error,
|
E: ser::Error,
|
||||||
@@ -879,6 +889,7 @@ mod content {
|
|||||||
error: PhantomData<E>,
|
error: PhantomData<E>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
|
||||||
impl<E> ser::SerializeMap for SerializeMap<E>
|
impl<E> ser::SerializeMap for SerializeMap<E>
|
||||||
where
|
where
|
||||||
E: ser::Error,
|
E: ser::Error,
|
||||||
@@ -930,6 +941,7 @@ mod content {
|
|||||||
error: PhantomData<E>,
|
error: PhantomData<E>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
|
||||||
impl<E> ser::SerializeStruct for SerializeStruct<E>
|
impl<E> ser::SerializeStruct for SerializeStruct<E>
|
||||||
where
|
where
|
||||||
E: ser::Error,
|
E: ser::Error,
|
||||||
@@ -959,6 +971,7 @@ mod content {
|
|||||||
error: PhantomData<E>,
|
error: PhantomData<E>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
|
||||||
impl<E> ser::SerializeStructVariant for SerializeStructVariant<E>
|
impl<E> ser::SerializeStructVariant for SerializeStructVariant<E>
|
||||||
where
|
where
|
||||||
E: ser::Error,
|
E: ser::Error,
|
||||||
@@ -1003,6 +1016,7 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(feature = "std", feature = "alloc"))]
|
#[cfg(any(feature = "std", feature = "alloc"))]
|
||||||
|
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
|
||||||
impl<'a, M> Serializer for FlatMapSerializer<'a, M>
|
impl<'a, M> Serializer for FlatMapSerializer<'a, M>
|
||||||
where
|
where
|
||||||
M: SerializeMap + 'a,
|
M: SerializeMap + 'a,
|
||||||
@@ -1184,6 +1198,7 @@ where
|
|||||||
pub struct FlatMapSerializeMap<'a, M: 'a>(&'a mut M);
|
pub struct FlatMapSerializeMap<'a, M: 'a>(&'a mut M);
|
||||||
|
|
||||||
#[cfg(any(feature = "std", feature = "alloc"))]
|
#[cfg(any(feature = "std", feature = "alloc"))]
|
||||||
|
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
|
||||||
impl<'a, M> ser::SerializeMap for FlatMapSerializeMap<'a, M>
|
impl<'a, M> ser::SerializeMap for FlatMapSerializeMap<'a, M>
|
||||||
where
|
where
|
||||||
M: SerializeMap + 'a,
|
M: SerializeMap + 'a,
|
||||||
@@ -1222,6 +1237,7 @@ where
|
|||||||
pub struct FlatMapSerializeStruct<'a, M: 'a>(&'a mut M);
|
pub struct FlatMapSerializeStruct<'a, M: 'a>(&'a mut M);
|
||||||
|
|
||||||
#[cfg(any(feature = "std", feature = "alloc"))]
|
#[cfg(any(feature = "std", feature = "alloc"))]
|
||||||
|
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
|
||||||
impl<'a, M> ser::SerializeStruct for FlatMapSerializeStruct<'a, M>
|
impl<'a, M> ser::SerializeStruct for FlatMapSerializeStruct<'a, M>
|
||||||
where
|
where
|
||||||
M: SerializeMap + 'a,
|
M: SerializeMap + 'a,
|
||||||
@@ -1263,6 +1279,7 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(feature = "std", feature = "alloc"))]
|
#[cfg(any(feature = "std", feature = "alloc"))]
|
||||||
|
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
|
||||||
impl<'a, M> ser::SerializeTupleVariant for FlatMapSerializeTupleVariantAsMapValue<'a, M>
|
impl<'a, M> ser::SerializeTupleVariant for FlatMapSerializeTupleVariantAsMapValue<'a, M>
|
||||||
where
|
where
|
||||||
M: SerializeMap + 'a,
|
M: SerializeMap + 'a,
|
||||||
@@ -1309,6 +1326,7 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(feature = "std", feature = "alloc"))]
|
#[cfg(any(feature = "std", feature = "alloc"))]
|
||||||
|
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
|
||||||
impl<'a, M> ser::SerializeStructVariant for FlatMapSerializeStructVariantAsMapValue<'a, M>
|
impl<'a, M> ser::SerializeStructVariant for FlatMapSerializeStructVariantAsMapValue<'a, M>
|
||||||
where
|
where
|
||||||
M: SerializeMap + 'a,
|
M: SerializeMap + 'a,
|
||||||
@@ -1339,6 +1357,7 @@ pub struct AdjacentlyTaggedEnumVariant {
|
|||||||
pub variant_name: &'static str,
|
pub variant_name: &'static str,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
|
||||||
impl Serialize for AdjacentlyTaggedEnumVariant {
|
impl Serialize for AdjacentlyTaggedEnumVariant {
|
||||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||||
where
|
where
|
||||||
@@ -1352,6 +1371,7 @@ impl Serialize for AdjacentlyTaggedEnumVariant {
|
|||||||
// that is not recognized.
|
// that is not recognized.
|
||||||
pub struct CannotSerializeVariant<T>(pub T);
|
pub struct CannotSerializeVariant<T>(pub T);
|
||||||
|
|
||||||
|
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
|
||||||
impl<T> Display for CannotSerializeVariant<T>
|
impl<T> Display for CannotSerializeVariant<T>
|
||||||
where
|
where
|
||||||
T: Debug,
|
T: Debug,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "serde_core"
|
name = "serde_core"
|
||||||
version = "1.0.221"
|
version = "1.0.225"
|
||||||
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>", "David Tolnay <dtolnay@gmail.com>"]
|
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>", "David Tolnay <dtolnay@gmail.com>"]
|
||||||
build = "build.rs"
|
build = "build.rs"
|
||||||
categories = ["encoding", "no-std", "no-std::no-alloc"]
|
categories = ["encoding", "no-std", "no-std::no-alloc"]
|
||||||
@@ -36,7 +36,7 @@ rustdoc-args = [
|
|||||||
# is compatible with exactly one serde release because the generated code
|
# is compatible with exactly one serde release because the generated code
|
||||||
# involves nonpublic APIs which are not bound by semver.
|
# involves nonpublic APIs which are not bound by semver.
|
||||||
[target.'cfg(any())'.dependencies]
|
[target.'cfg(any())'.dependencies]
|
||||||
serde_derive = { version = "=1.0.221", path = "../serde_derive" }
|
serde_derive = { version = "=1.0.225", path = "../serde_derive" }
|
||||||
|
|
||||||
|
|
||||||
### FEATURES #################################################################
|
### FEATURES #################################################################
|
||||||
|
|||||||
@@ -1,13 +1,28 @@
|
|||||||
use std::env;
|
use std::env;
|
||||||
|
use std::fs;
|
||||||
|
use std::path::PathBuf;
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
use std::str;
|
use std::str;
|
||||||
|
|
||||||
|
const PRIVATE: &str = "\
|
||||||
|
#[doc(hidden)]
|
||||||
|
pub mod __private$$ {
|
||||||
|
#[doc(hidden)]
|
||||||
|
pub use crate::private::*;
|
||||||
|
}
|
||||||
|
";
|
||||||
|
|
||||||
// The rustc-cfg strings below are *not* public API. Please let us know by
|
// The rustc-cfg strings below are *not* public API. Please let us know by
|
||||||
// opening a GitHub issue if your build environment requires some way to enable
|
// opening a GitHub issue if your build environment requires some way to enable
|
||||||
// these cfgs other than by executing our build script.
|
// these cfgs other than by executing our build script.
|
||||||
fn main() {
|
fn main() {
|
||||||
println!("cargo:rerun-if-changed=build.rs");
|
println!("cargo:rerun-if-changed=build.rs");
|
||||||
|
|
||||||
|
let out_dir = PathBuf::from(env::var_os("OUT_DIR").unwrap());
|
||||||
|
let patch_version = env::var("CARGO_PKG_VERSION_PATCH").unwrap();
|
||||||
|
let module = PRIVATE.replace("$$", &patch_version);
|
||||||
|
fs::write(out_dir.join("private.rs"), module).unwrap();
|
||||||
|
|
||||||
let minor = match rustc_minor_version() {
|
let minor = match rustc_minor_version() {
|
||||||
Some(minor) => minor,
|
Some(minor) => minor,
|
||||||
None => return,
|
None => return,
|
||||||
|
|||||||
+13
-4
@@ -35,7 +35,7 @@
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
// Serde types in rustdoc of other crates get linked to here.
|
// Serde types in rustdoc of other crates get linked to here.
|
||||||
#![doc(html_root_url = "https://docs.rs/serde/1.0.221")]
|
#![doc(html_root_url = "https://docs.rs/serde_core/1.0.225")]
|
||||||
// Support using Serde without the standard library!
|
// Support using Serde without the standard library!
|
||||||
#![cfg_attr(not(feature = "std"), no_std)]
|
#![cfg_attr(not(feature = "std"), no_std)]
|
||||||
// Show which crate feature enables conditionally compiled APIs in documentation.
|
// Show which crate feature enables conditionally compiled APIs in documentation.
|
||||||
@@ -252,9 +252,18 @@ pub use crate::ser::{Serialize, Serializer};
|
|||||||
|
|
||||||
// Used by generated code. Not public API.
|
// Used by generated code. Not public API.
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
#[path = "private/mod.rs"]
|
mod private;
|
||||||
pub mod __private;
|
|
||||||
use self::__private as private;
|
// Used by declarative macro generated code. Not public API.
|
||||||
|
#[doc(hidden)]
|
||||||
|
pub mod __private {
|
||||||
|
#[doc(hidden)]
|
||||||
|
pub use crate::private::doc;
|
||||||
|
#[doc(hidden)]
|
||||||
|
pub use core::result::Result;
|
||||||
|
}
|
||||||
|
|
||||||
|
include!(concat!(env!("OUT_DIR"), "/private.rs"));
|
||||||
|
|
||||||
#[cfg(all(not(feature = "std"), no_core_error))]
|
#[cfg(all(not(feature = "std"), no_core_error))]
|
||||||
mod std_error;
|
mod std_error;
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
use crate::de::{self, Deserialize, Deserializer, EnumAccess, MapAccess, SeqAccess, Visitor};
|
|
||||||
use crate::lib::*;
|
use crate::lib::*;
|
||||||
use crate::private::size_hint;
|
|
||||||
|
|
||||||
// Used from generated code to buffer the contents of the Deserializer when
|
// Used from generated code to buffer the contents of the Deserializer when
|
||||||
// deserializing untagged enums and internally tagged enums.
|
// deserializing untagged enums and internally tagged enums.
|
||||||
@@ -8,7 +6,6 @@ use crate::private::size_hint;
|
|||||||
// Not public API. Use serde-value instead.
|
// Not public API. Use serde-value instead.
|
||||||
//
|
//
|
||||||
// Obsoleted by format-specific buffer types (https://github.com/serde-rs/serde/pull/2912).
|
// Obsoleted by format-specific buffer types (https://github.com/serde-rs/serde/pull/2912).
|
||||||
#[derive(Clone)]
|
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
pub enum Content<'de> {
|
pub enum Content<'de> {
|
||||||
Bool(bool),
|
Bool(bool),
|
||||||
@@ -40,225 +37,3 @@ pub enum Content<'de> {
|
|||||||
Seq(Vec<Content<'de>>),
|
Seq(Vec<Content<'de>>),
|
||||||
Map(Vec<(Content<'de>, Content<'de>)>),
|
Map(Vec<(Content<'de>, Content<'de>)>),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'de> Deserialize<'de> for Content<'de> {
|
|
||||||
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
|
||||||
where
|
|
||||||
D: Deserializer<'de>,
|
|
||||||
{
|
|
||||||
// Untagged and internally tagged enums are only supported in
|
|
||||||
// self-describing formats.
|
|
||||||
let visitor = ContentVisitor { value: PhantomData };
|
|
||||||
deserializer.__deserialize_content_v1(visitor)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[doc(hidden)]
|
|
||||||
pub struct ContentVisitor<'de> {
|
|
||||||
value: PhantomData<Content<'de>>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'de> ContentVisitor<'de> {
|
|
||||||
pub fn new() -> Self {
|
|
||||||
ContentVisitor { value: PhantomData }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'de> Visitor<'de> for ContentVisitor<'de> {
|
|
||||||
type Value = Content<'de>;
|
|
||||||
|
|
||||||
fn expecting(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
|
||||||
fmt.write_str("any value")
|
|
||||||
}
|
|
||||||
|
|
||||||
fn visit_bool<F>(self, value: bool) -> Result<Self::Value, F>
|
|
||||||
where
|
|
||||||
F: de::Error,
|
|
||||||
{
|
|
||||||
Ok(Content::Bool(value))
|
|
||||||
}
|
|
||||||
|
|
||||||
fn visit_i8<F>(self, value: i8) -> Result<Self::Value, F>
|
|
||||||
where
|
|
||||||
F: de::Error,
|
|
||||||
{
|
|
||||||
Ok(Content::I8(value))
|
|
||||||
}
|
|
||||||
|
|
||||||
fn visit_i16<F>(self, value: i16) -> Result<Self::Value, F>
|
|
||||||
where
|
|
||||||
F: de::Error,
|
|
||||||
{
|
|
||||||
Ok(Content::I16(value))
|
|
||||||
}
|
|
||||||
|
|
||||||
fn visit_i32<F>(self, value: i32) -> Result<Self::Value, F>
|
|
||||||
where
|
|
||||||
F: de::Error,
|
|
||||||
{
|
|
||||||
Ok(Content::I32(value))
|
|
||||||
}
|
|
||||||
|
|
||||||
fn visit_i64<F>(self, value: i64) -> Result<Self::Value, F>
|
|
||||||
where
|
|
||||||
F: de::Error,
|
|
||||||
{
|
|
||||||
Ok(Content::I64(value))
|
|
||||||
}
|
|
||||||
|
|
||||||
fn visit_u8<F>(self, value: u8) -> Result<Self::Value, F>
|
|
||||||
where
|
|
||||||
F: de::Error,
|
|
||||||
{
|
|
||||||
Ok(Content::U8(value))
|
|
||||||
}
|
|
||||||
|
|
||||||
fn visit_u16<F>(self, value: u16) -> Result<Self::Value, F>
|
|
||||||
where
|
|
||||||
F: de::Error,
|
|
||||||
{
|
|
||||||
Ok(Content::U16(value))
|
|
||||||
}
|
|
||||||
|
|
||||||
fn visit_u32<F>(self, value: u32) -> Result<Self::Value, F>
|
|
||||||
where
|
|
||||||
F: de::Error,
|
|
||||||
{
|
|
||||||
Ok(Content::U32(value))
|
|
||||||
}
|
|
||||||
|
|
||||||
fn visit_u64<F>(self, value: u64) -> Result<Self::Value, F>
|
|
||||||
where
|
|
||||||
F: de::Error,
|
|
||||||
{
|
|
||||||
Ok(Content::U64(value))
|
|
||||||
}
|
|
||||||
|
|
||||||
fn visit_f32<F>(self, value: f32) -> Result<Self::Value, F>
|
|
||||||
where
|
|
||||||
F: de::Error,
|
|
||||||
{
|
|
||||||
Ok(Content::F32(value))
|
|
||||||
}
|
|
||||||
|
|
||||||
fn visit_f64<F>(self, value: f64) -> Result<Self::Value, F>
|
|
||||||
where
|
|
||||||
F: de::Error,
|
|
||||||
{
|
|
||||||
Ok(Content::F64(value))
|
|
||||||
}
|
|
||||||
|
|
||||||
fn visit_char<F>(self, value: char) -> Result<Self::Value, F>
|
|
||||||
where
|
|
||||||
F: de::Error,
|
|
||||||
{
|
|
||||||
Ok(Content::Char(value))
|
|
||||||
}
|
|
||||||
|
|
||||||
fn visit_str<F>(self, value: &str) -> Result<Self::Value, F>
|
|
||||||
where
|
|
||||||
F: de::Error,
|
|
||||||
{
|
|
||||||
Ok(Content::String(value.into()))
|
|
||||||
}
|
|
||||||
|
|
||||||
fn visit_borrowed_str<F>(self, value: &'de str) -> Result<Self::Value, F>
|
|
||||||
where
|
|
||||||
F: de::Error,
|
|
||||||
{
|
|
||||||
Ok(Content::Str(value))
|
|
||||||
}
|
|
||||||
|
|
||||||
fn visit_string<F>(self, value: String) -> Result<Self::Value, F>
|
|
||||||
where
|
|
||||||
F: de::Error,
|
|
||||||
{
|
|
||||||
Ok(Content::String(value))
|
|
||||||
}
|
|
||||||
|
|
||||||
fn visit_bytes<F>(self, value: &[u8]) -> Result<Self::Value, F>
|
|
||||||
where
|
|
||||||
F: de::Error,
|
|
||||||
{
|
|
||||||
Ok(Content::ByteBuf(value.into()))
|
|
||||||
}
|
|
||||||
|
|
||||||
fn visit_borrowed_bytes<F>(self, value: &'de [u8]) -> Result<Self::Value, F>
|
|
||||||
where
|
|
||||||
F: de::Error,
|
|
||||||
{
|
|
||||||
Ok(Content::Bytes(value))
|
|
||||||
}
|
|
||||||
|
|
||||||
fn visit_byte_buf<F>(self, value: Vec<u8>) -> Result<Self::Value, F>
|
|
||||||
where
|
|
||||||
F: de::Error,
|
|
||||||
{
|
|
||||||
Ok(Content::ByteBuf(value))
|
|
||||||
}
|
|
||||||
|
|
||||||
fn visit_unit<F>(self) -> Result<Self::Value, F>
|
|
||||||
where
|
|
||||||
F: de::Error,
|
|
||||||
{
|
|
||||||
Ok(Content::Unit)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn visit_none<F>(self) -> Result<Self::Value, F>
|
|
||||||
where
|
|
||||||
F: de::Error,
|
|
||||||
{
|
|
||||||
Ok(Content::None)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn visit_some<D>(self, deserializer: D) -> Result<Self::Value, D::Error>
|
|
||||||
where
|
|
||||||
D: Deserializer<'de>,
|
|
||||||
{
|
|
||||||
let v = tri!(Deserialize::deserialize(deserializer));
|
|
||||||
Ok(Content::Some(Box::new(v)))
|
|
||||||
}
|
|
||||||
|
|
||||||
fn visit_newtype_struct<D>(self, deserializer: D) -> Result<Self::Value, D::Error>
|
|
||||||
where
|
|
||||||
D: Deserializer<'de>,
|
|
||||||
{
|
|
||||||
let v = tri!(Deserialize::deserialize(deserializer));
|
|
||||||
Ok(Content::Newtype(Box::new(v)))
|
|
||||||
}
|
|
||||||
|
|
||||||
fn visit_seq<V>(self, mut visitor: V) -> Result<Self::Value, V::Error>
|
|
||||||
where
|
|
||||||
V: SeqAccess<'de>,
|
|
||||||
{
|
|
||||||
let mut vec =
|
|
||||||
Vec::<Content>::with_capacity(size_hint::cautious::<Content>(visitor.size_hint()));
|
|
||||||
while let Some(e) = tri!(visitor.next_element()) {
|
|
||||||
vec.push(e);
|
|
||||||
}
|
|
||||||
Ok(Content::Seq(vec))
|
|
||||||
}
|
|
||||||
|
|
||||||
fn visit_map<V>(self, mut visitor: V) -> Result<Self::Value, V::Error>
|
|
||||||
where
|
|
||||||
V: MapAccess<'de>,
|
|
||||||
{
|
|
||||||
let mut vec = Vec::<(Content, Content)>::with_capacity(size_hint::cautious::<(
|
|
||||||
Content,
|
|
||||||
Content,
|
|
||||||
)>(visitor.size_hint()));
|
|
||||||
while let Some(kv) = tri!(visitor.next_entry()) {
|
|
||||||
vec.push(kv);
|
|
||||||
}
|
|
||||||
Ok(Content::Map(vec))
|
|
||||||
}
|
|
||||||
|
|
||||||
fn visit_enum<V>(self, _visitor: V) -> Result<Self::Value, V::Error>
|
|
||||||
where
|
|
||||||
V: EnumAccess<'de>,
|
|
||||||
{
|
|
||||||
Err(de::Error::custom(
|
|
||||||
"untagged and internally tagged enums do not support enum input",
|
|
||||||
))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ use crate::ser;
|
|||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Error;
|
pub struct Error;
|
||||||
|
|
||||||
|
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
|
||||||
impl ser::Error for Error {
|
impl ser::Error for Error {
|
||||||
fn custom<T>(_: T) -> Self
|
fn custom<T>(_: T) -> Self
|
||||||
where
|
where
|
||||||
@@ -18,12 +19,14 @@ impl ser::Error for Error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
|
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
|
||||||
impl error::Error for Error {
|
impl error::Error for Error {
|
||||||
fn description(&self) -> &str {
|
fn description(&self) -> &str {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
|
||||||
impl Display for Error {
|
impl Display for Error {
|
||||||
fn fmt(&self, _: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, _: &mut fmt::Formatter) -> fmt::Result {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ pub mod string;
|
|||||||
|
|
||||||
#[cfg(all(not(no_serde_derive), any(feature = "std", feature = "alloc")))]
|
#[cfg(all(not(no_serde_derive), any(feature = "std", feature = "alloc")))]
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
pub use self::content::{Content, ContentVisitor};
|
pub use self::content::Content;
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
pub use self::seed::InPlaceSeed;
|
pub use self::seed::InPlaceSeed;
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ use crate::de::{Deserialize, DeserializeSeed, Deserializer};
|
|||||||
/// Wraps a mutable reference and calls deserialize_in_place on it.
|
/// Wraps a mutable reference and calls deserialize_in_place on it.
|
||||||
pub struct InPlaceSeed<'a, T: 'a>(pub &'a mut T);
|
pub struct InPlaceSeed<'a, T: 'a>(pub &'a mut T);
|
||||||
|
|
||||||
|
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
|
||||||
impl<'a, 'de, T> DeserializeSeed<'de> for InPlaceSeed<'a, T>
|
impl<'a, 'de, T> DeserializeSeed<'de> for InPlaceSeed<'a, T>
|
||||||
where
|
where
|
||||||
T: Deserialize<'de>,
|
T: Deserialize<'de>,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "serde_derive"
|
name = "serde_derive"
|
||||||
version = "1.0.221"
|
version = "1.0.225"
|
||||||
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>", "David Tolnay <dtolnay@gmail.com>"]
|
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>", "David Tolnay <dtolnay@gmail.com>"]
|
||||||
categories = ["no-std", "no-std::no-alloc"]
|
categories = ["no-std", "no-std::no-alloc"]
|
||||||
description = "Macros 1.1 implementation of #[derive(Serialize, Deserialize)]"
|
description = "Macros 1.1 implementation of #[derive(Serialize, Deserialize)]"
|
||||||
|
|||||||
+268
-262
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,56 @@
|
|||||||
|
use proc_macro2::TokenStream;
|
||||||
|
use quote::quote;
|
||||||
|
|
||||||
|
pub fn allow_deprecated(input: &syn::DeriveInput) -> Option<TokenStream> {
|
||||||
|
if should_allow_deprecated(input) {
|
||||||
|
Some(quote! { #[allow(deprecated)] })
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Determine if an `#[allow(deprecated)]` should be added to the derived impl.
|
||||||
|
///
|
||||||
|
/// This should happen if the derive input or an enum variant it contains has
|
||||||
|
/// one of:
|
||||||
|
/// - `#[deprecated]`
|
||||||
|
/// - `#[allow(deprecated)]`
|
||||||
|
fn should_allow_deprecated(input: &syn::DeriveInput) -> bool {
|
||||||
|
if contains_deprecated(&input.attrs) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if let syn::Data::Enum(data_enum) = &input.data {
|
||||||
|
for variant in &data_enum.variants {
|
||||||
|
if contains_deprecated(&variant.attrs) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
false
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Check whether the given attributes contains one of:
|
||||||
|
/// - `#[deprecated]`
|
||||||
|
/// - `#[allow(deprecated)]`
|
||||||
|
fn contains_deprecated(attrs: &[syn::Attribute]) -> bool {
|
||||||
|
for attr in attrs {
|
||||||
|
if attr.path().is_ident("deprecated") {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if let syn::Meta::List(meta_list) = &attr.meta {
|
||||||
|
if meta_list.path.is_ident("allow") {
|
||||||
|
let mut allow_deprecated = false;
|
||||||
|
let _ = meta_list.parse_nested_meta(|meta| {
|
||||||
|
if meta.path.is_ident("deprecated") {
|
||||||
|
allow_deprecated = true;
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
});
|
||||||
|
if allow_deprecated {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
false
|
||||||
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
//! A Serde ast, parsed from the Syn ast and ready to generate Rust code.
|
//! A Serde ast, parsed from the Syn ast and ready to generate Rust code.
|
||||||
|
|
||||||
use crate::internals::{attr, check, Ctxt, Derive};
|
use crate::internals::{attr, check, Ctxt, Derive};
|
||||||
|
use proc_macro2::Ident;
|
||||||
use syn::punctuated::Punctuated;
|
use syn::punctuated::Punctuated;
|
||||||
use syn::Token;
|
use syn::Token;
|
||||||
|
|
||||||
@@ -62,13 +63,17 @@ impl<'a> Container<'a> {
|
|||||||
cx: &Ctxt,
|
cx: &Ctxt,
|
||||||
item: &'a syn::DeriveInput,
|
item: &'a syn::DeriveInput,
|
||||||
derive: Derive,
|
derive: Derive,
|
||||||
|
private: &Ident,
|
||||||
) -> Option<Container<'a>> {
|
) -> Option<Container<'a>> {
|
||||||
let attrs = attr::Container::from_ast(cx, item);
|
let attrs = attr::Container::from_ast(cx, item);
|
||||||
|
|
||||||
let mut data = match &item.data {
|
let mut data = match &item.data {
|
||||||
syn::Data::Enum(data) => Data::Enum(enum_from_ast(cx, &data.variants, attrs.default())),
|
syn::Data::Enum(data) => {
|
||||||
|
Data::Enum(enum_from_ast(cx, &data.variants, attrs.default(), private))
|
||||||
|
}
|
||||||
syn::Data::Struct(data) => {
|
syn::Data::Struct(data) => {
|
||||||
let (style, fields) = struct_from_ast(cx, &data.fields, None, attrs.default());
|
let (style, fields) =
|
||||||
|
struct_from_ast(cx, &data.fields, None, attrs.default(), private);
|
||||||
Data::Struct(style, fields)
|
Data::Struct(style, fields)
|
||||||
}
|
}
|
||||||
syn::Data::Union(_) => {
|
syn::Data::Union(_) => {
|
||||||
@@ -129,13 +134,19 @@ fn enum_from_ast<'a>(
|
|||||||
cx: &Ctxt,
|
cx: &Ctxt,
|
||||||
variants: &'a Punctuated<syn::Variant, Token![,]>,
|
variants: &'a Punctuated<syn::Variant, Token![,]>,
|
||||||
container_default: &attr::Default,
|
container_default: &attr::Default,
|
||||||
|
private: &Ident,
|
||||||
) -> Vec<Variant<'a>> {
|
) -> Vec<Variant<'a>> {
|
||||||
let variants: Vec<Variant> = variants
|
let variants: Vec<Variant> = variants
|
||||||
.iter()
|
.iter()
|
||||||
.map(|variant| {
|
.map(|variant| {
|
||||||
let attrs = attr::Variant::from_ast(cx, variant);
|
let attrs = attr::Variant::from_ast(cx, variant);
|
||||||
let (style, fields) =
|
let (style, fields) = struct_from_ast(
|
||||||
struct_from_ast(cx, &variant.fields, Some(&attrs), container_default);
|
cx,
|
||||||
|
&variant.fields,
|
||||||
|
Some(&attrs),
|
||||||
|
container_default,
|
||||||
|
private,
|
||||||
|
);
|
||||||
Variant {
|
Variant {
|
||||||
ident: variant.ident.clone(),
|
ident: variant.ident.clone(),
|
||||||
attrs,
|
attrs,
|
||||||
@@ -165,19 +176,20 @@ fn struct_from_ast<'a>(
|
|||||||
fields: &'a syn::Fields,
|
fields: &'a syn::Fields,
|
||||||
attrs: Option<&attr::Variant>,
|
attrs: Option<&attr::Variant>,
|
||||||
container_default: &attr::Default,
|
container_default: &attr::Default,
|
||||||
|
private: &Ident,
|
||||||
) -> (Style, Vec<Field<'a>>) {
|
) -> (Style, Vec<Field<'a>>) {
|
||||||
match fields {
|
match fields {
|
||||||
syn::Fields::Named(fields) => (
|
syn::Fields::Named(fields) => (
|
||||||
Style::Struct,
|
Style::Struct,
|
||||||
fields_from_ast(cx, &fields.named, attrs, container_default),
|
fields_from_ast(cx, &fields.named, attrs, container_default, private),
|
||||||
),
|
),
|
||||||
syn::Fields::Unnamed(fields) if fields.unnamed.len() == 1 => (
|
syn::Fields::Unnamed(fields) if fields.unnamed.len() == 1 => (
|
||||||
Style::Newtype,
|
Style::Newtype,
|
||||||
fields_from_ast(cx, &fields.unnamed, attrs, container_default),
|
fields_from_ast(cx, &fields.unnamed, attrs, container_default, private),
|
||||||
),
|
),
|
||||||
syn::Fields::Unnamed(fields) => (
|
syn::Fields::Unnamed(fields) => (
|
||||||
Style::Tuple,
|
Style::Tuple,
|
||||||
fields_from_ast(cx, &fields.unnamed, attrs, container_default),
|
fields_from_ast(cx, &fields.unnamed, attrs, container_default, private),
|
||||||
),
|
),
|
||||||
syn::Fields::Unit => (Style::Unit, Vec::new()),
|
syn::Fields::Unit => (Style::Unit, Vec::new()),
|
||||||
}
|
}
|
||||||
@@ -188,6 +200,7 @@ fn fields_from_ast<'a>(
|
|||||||
fields: &'a Punctuated<syn::Field, Token![,]>,
|
fields: &'a Punctuated<syn::Field, Token![,]>,
|
||||||
attrs: Option<&attr::Variant>,
|
attrs: Option<&attr::Variant>,
|
||||||
container_default: &attr::Default,
|
container_default: &attr::Default,
|
||||||
|
private: &Ident,
|
||||||
) -> Vec<Field<'a>> {
|
) -> Vec<Field<'a>> {
|
||||||
fields
|
fields
|
||||||
.iter()
|
.iter()
|
||||||
@@ -197,7 +210,7 @@ fn fields_from_ast<'a>(
|
|||||||
Some(ident) => syn::Member::Named(ident.clone()),
|
Some(ident) => syn::Member::Named(ident.clone()),
|
||||||
None => syn::Member::Unnamed(i.into()),
|
None => syn::Member::Unnamed(i.into()),
|
||||||
},
|
},
|
||||||
attrs: attr::Field::from_ast(cx, i, field, attrs, container_default),
|
attrs: attr::Field::from_ast(cx, i, field, attrs, container_default, private),
|
||||||
ty: &field.ty,
|
ty: &field.ty,
|
||||||
original: field,
|
original: field,
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -3,14 +3,13 @@ use crate::internals::symbol::*;
|
|||||||
use crate::internals::{ungroup, Ctxt};
|
use crate::internals::{ungroup, Ctxt};
|
||||||
use proc_macro2::{Spacing, Span, TokenStream, TokenTree};
|
use proc_macro2::{Spacing, Span, TokenStream, TokenTree};
|
||||||
use quote::ToTokens;
|
use quote::ToTokens;
|
||||||
use std::borrow::Cow;
|
|
||||||
use std::collections::BTreeSet;
|
use std::collections::BTreeSet;
|
||||||
use std::iter::FromIterator;
|
use std::iter::FromIterator;
|
||||||
use syn::meta::ParseNestedMeta;
|
use syn::meta::ParseNestedMeta;
|
||||||
use syn::parse::ParseStream;
|
use syn::parse::ParseStream;
|
||||||
use syn::punctuated::Punctuated;
|
use syn::punctuated::Punctuated;
|
||||||
use syn::spanned::Spanned;
|
use syn::spanned::Spanned;
|
||||||
use syn::{parse_quote, token, Ident, Lifetime, Token};
|
use syn::{token, Ident, Lifetime, Token};
|
||||||
|
|
||||||
// This module handles parsing of `#[serde(...)]` attributes. The entrypoints
|
// This module handles parsing of `#[serde(...)]` attributes. The entrypoints
|
||||||
// are `attr::Container::from_ast`, `attr::Variant::from_ast`, and
|
// are `attr::Container::from_ast`, `attr::Variant::from_ast`, and
|
||||||
@@ -609,11 +608,6 @@ impl Container {
|
|||||||
self.serde_path.as_ref()
|
self.serde_path.as_ref()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn serde_path(&self) -> Cow<syn::Path> {
|
|
||||||
self.custom_serde_path()
|
|
||||||
.map_or_else(|| Cow::Owned(parse_quote!(_serde)), Cow::Borrowed)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Error message generated when type can't be deserialized.
|
/// Error message generated when type can't be deserialized.
|
||||||
/// If `None`, default message will be used
|
/// If `None`, default message will be used
|
||||||
pub fn expecting(&self) -> Option<&str> {
|
pub fn expecting(&self) -> Option<&str> {
|
||||||
@@ -1024,6 +1018,7 @@ impl Field {
|
|||||||
field: &syn::Field,
|
field: &syn::Field,
|
||||||
attrs: Option<&Variant>,
|
attrs: Option<&Variant>,
|
||||||
container_default: &Default,
|
container_default: &Default,
|
||||||
|
private: &Ident,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let mut ser_name = Attr::none(cx, RENAME);
|
let mut ser_name = Attr::none(cx, RENAME);
|
||||||
let mut de_name = Attr::none(cx, RENAME);
|
let mut de_name = Attr::none(cx, RENAME);
|
||||||
@@ -1217,7 +1212,7 @@ impl Field {
|
|||||||
};
|
};
|
||||||
let span = Span::call_site();
|
let span = Span::call_site();
|
||||||
path.segments.push(Ident::new("_serde", span).into());
|
path.segments.push(Ident::new("_serde", span).into());
|
||||||
path.segments.push(Ident::new("__private", span).into());
|
path.segments.push(private.clone().into());
|
||||||
path.segments.push(Ident::new("de", span).into());
|
path.segments.push(Ident::new("de", span).into());
|
||||||
path.segments
|
path.segments
|
||||||
.push(Ident::new("borrow_cow_str", span).into());
|
.push(Ident::new("borrow_cow_str", span).into());
|
||||||
@@ -1234,7 +1229,7 @@ impl Field {
|
|||||||
};
|
};
|
||||||
let span = Span::call_site();
|
let span = Span::call_site();
|
||||||
path.segments.push(Ident::new("_serde", span).into());
|
path.segments.push(Ident::new("_serde", span).into());
|
||||||
path.segments.push(Ident::new("__private", span).into());
|
path.segments.push(private.clone().into());
|
||||||
path.segments.push(Ident::new("de", span).into());
|
path.segments.push(Ident::new("de", span).into());
|
||||||
path.segments
|
path.segments
|
||||||
.push(Ident::new("borrow_cow_bytes", span).into());
|
.push(Ident::new("borrow_cow_bytes", span).into());
|
||||||
|
|||||||
+22
-1
@@ -13,7 +13,7 @@
|
|||||||
//!
|
//!
|
||||||
//! [https://serde.rs/derive.html]: https://serde.rs/derive.html
|
//! [https://serde.rs/derive.html]: https://serde.rs/derive.html
|
||||||
|
|
||||||
#![doc(html_root_url = "https://docs.rs/serde_derive/1.0.221")]
|
#![doc(html_root_url = "https://docs.rs/serde_derive/1.0.225")]
|
||||||
#![cfg_attr(not(check_cfg), allow(unexpected_cfgs))]
|
#![cfg_attr(not(check_cfg), allow(unexpected_cfgs))]
|
||||||
// Ignored clippy lints
|
// Ignored clippy lints
|
||||||
#![allow(
|
#![allow(
|
||||||
@@ -75,6 +75,8 @@ extern crate proc_macro;
|
|||||||
mod internals;
|
mod internals;
|
||||||
|
|
||||||
use proc_macro::TokenStream;
|
use proc_macro::TokenStream;
|
||||||
|
use proc_macro2::{Ident, Span};
|
||||||
|
use quote::{ToTokens, TokenStreamExt as _};
|
||||||
use syn::parse_macro_input;
|
use syn::parse_macro_input;
|
||||||
use syn::DeriveInput;
|
use syn::DeriveInput;
|
||||||
|
|
||||||
@@ -84,11 +86,30 @@ mod bound;
|
|||||||
mod fragment;
|
mod fragment;
|
||||||
|
|
||||||
mod de;
|
mod de;
|
||||||
|
mod deprecated;
|
||||||
mod dummy;
|
mod dummy;
|
||||||
mod pretend;
|
mod pretend;
|
||||||
mod ser;
|
mod ser;
|
||||||
mod this;
|
mod this;
|
||||||
|
|
||||||
|
#[allow(non_camel_case_types)]
|
||||||
|
struct private;
|
||||||
|
|
||||||
|
impl private {
|
||||||
|
fn ident(&self) -> Ident {
|
||||||
|
Ident::new(
|
||||||
|
concat!("__private", env!("CARGO_PKG_VERSION_PATCH")),
|
||||||
|
Span::call_site(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ToTokens for private {
|
||||||
|
fn to_tokens(&self, tokens: &mut proc_macro2::TokenStream) {
|
||||||
|
tokens.append(self.ident());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[proc_macro_derive(Serialize, attributes(serde))]
|
#[proc_macro_derive(Serialize, attributes(serde))]
|
||||||
pub fn derive_serialize(input: TokenStream) -> TokenStream {
|
pub fn derive_serialize(input: TokenStream) -> TokenStream {
|
||||||
let mut input = parse_macro_input!(input as DeriveInput);
|
let mut input = parse_macro_input!(input as DeriveInput);
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
use crate::internals::ast::{Container, Data, Field, Style, Variant};
|
use crate::internals::ast::{Container, Data, Field, Style, Variant};
|
||||||
|
use crate::private;
|
||||||
use proc_macro2::TokenStream;
|
use proc_macro2::TokenStream;
|
||||||
use quote::{format_ident, quote};
|
use quote::{format_ident, quote};
|
||||||
|
|
||||||
@@ -83,8 +84,8 @@ fn pretend_fields_used_struct(cont: &Container, fields: &[Field]) -> TokenStream
|
|||||||
let placeholders = (0usize..).map(|i| format_ident!("__v{}", i));
|
let placeholders = (0usize..).map(|i| format_ident!("__v{}", i));
|
||||||
|
|
||||||
quote! {
|
quote! {
|
||||||
match _serde::__private::None::<&#type_ident #ty_generics> {
|
match _serde::#private::None::<&#type_ident #ty_generics> {
|
||||||
_serde::__private::Some(#type_ident { #(#members: #placeholders),* }) => {}
|
_serde::#private::Some(#type_ident { #(#members: #placeholders),* }) => {}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -96,11 +97,12 @@ fn pretend_fields_used_struct_packed(cont: &Container, fields: &[Field]) -> Toke
|
|||||||
|
|
||||||
let members = fields.iter().map(|field| &field.member).collect::<Vec<_>>();
|
let members = fields.iter().map(|field| &field.member).collect::<Vec<_>>();
|
||||||
|
|
||||||
|
let private2 = private;
|
||||||
quote! {
|
quote! {
|
||||||
match _serde::__private::None::<&#type_ident #ty_generics> {
|
match _serde::#private::None::<&#type_ident #ty_generics> {
|
||||||
_serde::__private::Some(__v @ #type_ident { #(#members: _),* }) => {
|
_serde::#private::Some(__v @ #type_ident { #(#members: _),* }) => {
|
||||||
#(
|
#(
|
||||||
let _ = _serde::__private::ptr::addr_of!(__v.#members);
|
let _ = _serde::#private2::ptr::addr_of!(__v.#members);
|
||||||
)*
|
)*
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
@@ -125,10 +127,11 @@ fn pretend_fields_used_enum(cont: &Container, variants: &[Variant]) -> TokenStre
|
|||||||
})
|
})
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
|
let private2 = private;
|
||||||
quote! {
|
quote! {
|
||||||
match _serde::__private::None::<&#type_ident #ty_generics> {
|
match _serde::#private::None::<&#type_ident #ty_generics> {
|
||||||
#(
|
#(
|
||||||
_serde::__private::Some(#patterns) => {}
|
_serde::#private2::Some(#patterns) => {}
|
||||||
)*
|
)*
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
@@ -172,8 +175,8 @@ fn pretend_variants_used(cont: &Container) -> TokenStream {
|
|||||||
};
|
};
|
||||||
|
|
||||||
quote! {
|
quote! {
|
||||||
match _serde::__private::None {
|
match _serde::#private::None {
|
||||||
_serde::__private::Some((#(#placeholders,)*)) => {
|
_serde::#private::Some((#(#placeholders,)*)) => {
|
||||||
let _ = #type_ident::#variant_ident #turbofish #pat;
|
let _ = #type_ident::#variant_ident #turbofish #pat;
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
|
|||||||
+35
-32
@@ -1,8 +1,9 @@
|
|||||||
|
use crate::deprecated::allow_deprecated;
|
||||||
use crate::fragment::{Fragment, Match, Stmts};
|
use crate::fragment::{Fragment, Match, Stmts};
|
||||||
use crate::internals::ast::{Container, Data, Field, Style, Variant};
|
use crate::internals::ast::{Container, Data, Field, Style, Variant};
|
||||||
use crate::internals::name::Name;
|
use crate::internals::name::Name;
|
||||||
use crate::internals::{attr, replace_receiver, Ctxt, Derive};
|
use crate::internals::{attr, replace_receiver, Ctxt, Derive};
|
||||||
use crate::{bound, dummy, pretend, this};
|
use crate::{bound, dummy, pretend, private, this};
|
||||||
use proc_macro2::{Span, TokenStream};
|
use proc_macro2::{Span, TokenStream};
|
||||||
use quote::{quote, quote_spanned};
|
use quote::{quote, quote_spanned};
|
||||||
use syn::spanned::Spanned;
|
use syn::spanned::Spanned;
|
||||||
@@ -12,7 +13,7 @@ pub fn expand_derive_serialize(input: &mut syn::DeriveInput) -> syn::Result<Toke
|
|||||||
replace_receiver(input);
|
replace_receiver(input);
|
||||||
|
|
||||||
let ctxt = Ctxt::new();
|
let ctxt = Ctxt::new();
|
||||||
let cont = match Container::from_ast(&ctxt, input, Derive::Serialize) {
|
let cont = match Container::from_ast(&ctxt, input, Derive::Serialize, &private.ident()) {
|
||||||
Some(cont) => cont,
|
Some(cont) => cont,
|
||||||
None => return Err(ctxt.check().unwrap_err()),
|
None => return Err(ctxt.check().unwrap_err()),
|
||||||
};
|
};
|
||||||
@@ -23,17 +24,18 @@ pub fn expand_derive_serialize(input: &mut syn::DeriveInput) -> syn::Result<Toke
|
|||||||
let params = Parameters::new(&cont);
|
let params = Parameters::new(&cont);
|
||||||
let (impl_generics, ty_generics, where_clause) = params.generics.split_for_impl();
|
let (impl_generics, ty_generics, where_clause) = params.generics.split_for_impl();
|
||||||
let body = Stmts(serialize_body(&cont, ¶ms));
|
let body = Stmts(serialize_body(&cont, ¶ms));
|
||||||
let serde = cont.attrs.serde_path();
|
let allow_deprecated = allow_deprecated(input);
|
||||||
|
|
||||||
let impl_block = if let Some(remote) = cont.attrs.remote() {
|
let impl_block = if let Some(remote) = cont.attrs.remote() {
|
||||||
let vis = &input.vis;
|
let vis = &input.vis;
|
||||||
let used = pretend::pretend_used(&cont, params.is_packed);
|
let used = pretend::pretend_used(&cont, params.is_packed);
|
||||||
quote! {
|
quote! {
|
||||||
#[automatically_derived]
|
#[automatically_derived]
|
||||||
|
#allow_deprecated
|
||||||
impl #impl_generics #ident #ty_generics #where_clause {
|
impl #impl_generics #ident #ty_generics #where_clause {
|
||||||
#vis fn serialize<__S>(__self: &#remote #ty_generics, __serializer: __S) -> #serde::__private::Result<__S::Ok, __S::Error>
|
#vis fn serialize<__S>(__self: &#remote #ty_generics, __serializer: __S) -> _serde::#private::Result<__S::Ok, __S::Error>
|
||||||
where
|
where
|
||||||
__S: #serde::Serializer,
|
__S: _serde::Serializer,
|
||||||
{
|
{
|
||||||
#used
|
#used
|
||||||
#body
|
#body
|
||||||
@@ -43,10 +45,11 @@ pub fn expand_derive_serialize(input: &mut syn::DeriveInput) -> syn::Result<Toke
|
|||||||
} else {
|
} else {
|
||||||
quote! {
|
quote! {
|
||||||
#[automatically_derived]
|
#[automatically_derived]
|
||||||
impl #impl_generics #serde::Serialize for #ident #ty_generics #where_clause {
|
#allow_deprecated
|
||||||
fn serialize<__S>(&self, __serializer: __S) -> #serde::__private::Result<__S::Ok, __S::Error>
|
impl #impl_generics _serde::Serialize for #ident #ty_generics #where_clause {
|
||||||
|
fn serialize<__S>(&self, __serializer: __S) -> _serde::#private::Result<__S::Ok, __S::Error>
|
||||||
where
|
where
|
||||||
__S: #serde::Serializer,
|
__S: _serde::Serializer,
|
||||||
{
|
{
|
||||||
#body
|
#body
|
||||||
}
|
}
|
||||||
@@ -212,7 +215,7 @@ fn serialize_into(params: &Parameters, type_into: &syn::Type) -> Fragment {
|
|||||||
let self_var = ¶ms.self_var;
|
let self_var = ¶ms.self_var;
|
||||||
quote_block! {
|
quote_block! {
|
||||||
_serde::Serialize::serialize(
|
_serde::Serialize::serialize(
|
||||||
&_serde::__private::Into::<#type_into>::into(_serde::__private::Clone::clone(#self_var)),
|
&_serde::#private::Into::<#type_into>::into(_serde::#private::Clone::clone(#self_var)),
|
||||||
__serializer)
|
__serializer)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -382,7 +385,7 @@ fn serialize_struct_as_map(
|
|||||||
let let_mut = mut_if(serialized_fields.peek().is_some() || tag_field_exists);
|
let let_mut = mut_if(serialized_fields.peek().is_some() || tag_field_exists);
|
||||||
|
|
||||||
quote_block! {
|
quote_block! {
|
||||||
let #let_mut __serde_state = _serde::Serializer::serialize_map(__serializer, _serde::__private::None)?;
|
let #let_mut __serde_state = _serde::Serializer::serialize_map(__serializer, _serde::#private::None)?;
|
||||||
#tag_field
|
#tag_field
|
||||||
#(#serialize_fields)*
|
#(#serialize_fields)*
|
||||||
_serde::ser::SerializeMap::end(__serde_state)
|
_serde::ser::SerializeMap::end(__serde_state)
|
||||||
@@ -404,7 +407,7 @@ fn serialize_enum(params: &Parameters, variants: &[Variant], cattrs: &attr::Cont
|
|||||||
|
|
||||||
if cattrs.remote().is_some() && cattrs.non_exhaustive() {
|
if cattrs.remote().is_some() && cattrs.non_exhaustive() {
|
||||||
arms.push(quote! {
|
arms.push(quote! {
|
||||||
ref unrecognized => _serde::__private::Err(_serde::ser::Error::custom(_serde::__private::ser::CannotSerializeVariant(unrecognized))),
|
ref unrecognized => _serde::#private::Err(_serde::ser::Error::custom(_serde::#private::ser::CannotSerializeVariant(unrecognized))),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -431,7 +434,7 @@ fn serialize_variant(
|
|||||||
variant_ident
|
variant_ident
|
||||||
);
|
);
|
||||||
let skipped_err = quote! {
|
let skipped_err = quote! {
|
||||||
_serde::__private::Err(_serde::ser::Error::custom(#skipped_msg))
|
_serde::#private::Err(_serde::ser::Error::custom(#skipped_msg))
|
||||||
};
|
};
|
||||||
let fields_pat = match variant.style {
|
let fields_pat = match variant.style {
|
||||||
Style::Unit => quote!(),
|
Style::Unit => quote!(),
|
||||||
@@ -585,7 +588,7 @@ fn serialize_internally_tagged_variant(
|
|||||||
if let Some(path) = variant.attrs.serialize_with() {
|
if let Some(path) = variant.attrs.serialize_with() {
|
||||||
let ser = wrap_serialize_variant_with(params, path, variant);
|
let ser = wrap_serialize_variant_with(params, path, variant);
|
||||||
return quote_expr! {
|
return quote_expr! {
|
||||||
_serde::__private::ser::serialize_tagged_newtype(
|
_serde::#private::ser::serialize_tagged_newtype(
|
||||||
__serializer,
|
__serializer,
|
||||||
#enum_ident_str,
|
#enum_ident_str,
|
||||||
#variant_ident_str,
|
#variant_ident_str,
|
||||||
@@ -614,7 +617,7 @@ fn serialize_internally_tagged_variant(
|
|||||||
}
|
}
|
||||||
|
|
||||||
let span = field.original.span();
|
let span = field.original.span();
|
||||||
let func = quote_spanned!(span=> _serde::__private::ser::serialize_tagged_newtype);
|
let func = quote_spanned!(span=> _serde::#private::ser::serialize_tagged_newtype);
|
||||||
quote_expr! {
|
quote_expr! {
|
||||||
#func(
|
#func(
|
||||||
__serializer,
|
__serializer,
|
||||||
@@ -648,7 +651,7 @@ fn serialize_adjacently_tagged_variant(
|
|||||||
let type_name = cattrs.name().serialize_name();
|
let type_name = cattrs.name().serialize_name();
|
||||||
let variant_name = variant.attrs.name().serialize_name();
|
let variant_name = variant.attrs.name().serialize_name();
|
||||||
let serialize_variant = quote! {
|
let serialize_variant = quote! {
|
||||||
&_serde::__private::ser::AdjacentlyTaggedEnumVariant {
|
&_serde::#private::ser::AdjacentlyTaggedEnumVariant {
|
||||||
enum_name: #type_name,
|
enum_name: #type_name,
|
||||||
variant_index: #variant_index,
|
variant_index: #variant_index,
|
||||||
variant_name: #variant_name,
|
variant_name: #variant_name,
|
||||||
@@ -731,12 +734,12 @@ fn serialize_adjacently_tagged_variant(
|
|||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
struct __AdjacentlyTagged #wrapper_generics #where_clause {
|
struct __AdjacentlyTagged #wrapper_generics #where_clause {
|
||||||
data: (#(&'__a #fields_ty,)*),
|
data: (#(&'__a #fields_ty,)*),
|
||||||
phantom: _serde::__private::PhantomData<#this_type #ty_generics>,
|
phantom: _serde::#private::PhantomData<#this_type #ty_generics>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[automatically_derived]
|
#[automatically_derived]
|
||||||
impl #wrapper_impl_generics _serde::Serialize for __AdjacentlyTagged #wrapper_ty_generics #where_clause {
|
impl #wrapper_impl_generics _serde::Serialize for __AdjacentlyTagged #wrapper_ty_generics #where_clause {
|
||||||
fn serialize<__S>(&self, __serializer: __S) -> _serde::__private::Result<__S::Ok, __S::Error>
|
fn serialize<__S>(&self, __serializer: __S) -> _serde::#private::Result<__S::Ok, __S::Error>
|
||||||
where
|
where
|
||||||
__S: _serde::Serializer,
|
__S: _serde::Serializer,
|
||||||
{
|
{
|
||||||
@@ -754,7 +757,7 @@ fn serialize_adjacently_tagged_variant(
|
|||||||
_serde::ser::SerializeStruct::serialize_field(
|
_serde::ser::SerializeStruct::serialize_field(
|
||||||
&mut __struct, #content, &__AdjacentlyTagged {
|
&mut __struct, #content, &__AdjacentlyTagged {
|
||||||
data: (#(#fields_ident,)*),
|
data: (#(#fields_ident,)*),
|
||||||
phantom: _serde::__private::PhantomData::<#this_type #ty_generics>,
|
phantom: _serde::#private::PhantomData::<#this_type #ty_generics>,
|
||||||
})?;
|
})?;
|
||||||
_serde::ser::SerializeStruct::end(__struct)
|
_serde::ser::SerializeStruct::end(__struct)
|
||||||
}
|
}
|
||||||
@@ -996,19 +999,19 @@ fn serialize_struct_variant_with_flatten(
|
|||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
struct __EnumFlatten #wrapper_generics #where_clause {
|
struct __EnumFlatten #wrapper_generics #where_clause {
|
||||||
data: (#(&'__a #fields_ty,)*),
|
data: (#(&'__a #fields_ty,)*),
|
||||||
phantom: _serde::__private::PhantomData<#this_type #ty_generics>,
|
phantom: _serde::#private::PhantomData<#this_type #ty_generics>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[automatically_derived]
|
#[automatically_derived]
|
||||||
impl #wrapper_impl_generics _serde::Serialize for __EnumFlatten #wrapper_ty_generics #where_clause {
|
impl #wrapper_impl_generics _serde::Serialize for __EnumFlatten #wrapper_ty_generics #where_clause {
|
||||||
fn serialize<__S>(&self, __serializer: __S) -> _serde::__private::Result<__S::Ok, __S::Error>
|
fn serialize<__S>(&self, __serializer: __S) -> _serde::#private::Result<__S::Ok, __S::Error>
|
||||||
where
|
where
|
||||||
__S: _serde::Serializer,
|
__S: _serde::Serializer,
|
||||||
{
|
{
|
||||||
let (#(#members,)*) = self.data;
|
let (#(#members,)*) = self.data;
|
||||||
let #let_mut __serde_state = _serde::Serializer::serialize_map(
|
let #let_mut __serde_state = _serde::Serializer::serialize_map(
|
||||||
__serializer,
|
__serializer,
|
||||||
_serde::__private::None)?;
|
_serde::#private::None)?;
|
||||||
#(#serialize_fields)*
|
#(#serialize_fields)*
|
||||||
_serde::ser::SerializeMap::end(__serde_state)
|
_serde::ser::SerializeMap::end(__serde_state)
|
||||||
}
|
}
|
||||||
@@ -1021,7 +1024,7 @@ fn serialize_struct_variant_with_flatten(
|
|||||||
#variant_name,
|
#variant_name,
|
||||||
&__EnumFlatten {
|
&__EnumFlatten {
|
||||||
data: (#(#members,)*),
|
data: (#(#members,)*),
|
||||||
phantom: _serde::__private::PhantomData::<#this_type #ty_generics>,
|
phantom: _serde::#private::PhantomData::<#this_type #ty_generics>,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1029,7 +1032,7 @@ fn serialize_struct_variant_with_flatten(
|
|||||||
quote_block! {
|
quote_block! {
|
||||||
let #let_mut __serde_state = _serde::Serializer::serialize_map(
|
let #let_mut __serde_state = _serde::Serializer::serialize_map(
|
||||||
__serializer,
|
__serializer,
|
||||||
_serde::__private::None)?;
|
_serde::#private::None)?;
|
||||||
_serde::ser::SerializeMap::serialize_entry(
|
_serde::ser::SerializeMap::serialize_entry(
|
||||||
&mut __serde_state,
|
&mut __serde_state,
|
||||||
#tag,
|
#tag,
|
||||||
@@ -1043,7 +1046,7 @@ fn serialize_struct_variant_with_flatten(
|
|||||||
quote_block! {
|
quote_block! {
|
||||||
let #let_mut __serde_state = _serde::Serializer::serialize_map(
|
let #let_mut __serde_state = _serde::Serializer::serialize_map(
|
||||||
__serializer,
|
__serializer,
|
||||||
_serde::__private::None)?;
|
_serde::#private::None)?;
|
||||||
#(#serialize_fields)*
|
#(#serialize_fields)*
|
||||||
_serde::ser::SerializeMap::end(__serde_state)
|
_serde::ser::SerializeMap::end(__serde_state)
|
||||||
}
|
}
|
||||||
@@ -1132,7 +1135,7 @@ fn serialize_struct_visitor(
|
|||||||
let ser = if field.attrs.flatten() {
|
let ser = if field.attrs.flatten() {
|
||||||
let func = quote_spanned!(span=> _serde::Serialize::serialize);
|
let func = quote_spanned!(span=> _serde::Serialize::serialize);
|
||||||
quote! {
|
quote! {
|
||||||
#func(&#field_expr, _serde::__private::ser::FlatMapSerializer(&mut __serde_state))?;
|
#func(&#field_expr, _serde::#private::ser::FlatMapSerializer(&mut __serde_state))?;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let func = struct_trait.serialize_field(span);
|
let func = struct_trait.serialize_field(span);
|
||||||
@@ -1235,16 +1238,16 @@ fn wrap_serialize_with(
|
|||||||
#serialize_with(#(#self_var.values.#field_access, )* #serializer_var)
|
#serialize_with(#(#self_var.values.#field_access, )* #serializer_var)
|
||||||
};
|
};
|
||||||
|
|
||||||
quote!({
|
quote!(&{
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
struct __SerializeWith #wrapper_impl_generics #where_clause {
|
struct __SerializeWith #wrapper_impl_generics #where_clause {
|
||||||
values: (#(&'__a #field_tys, )*),
|
values: (#(&'__a #field_tys, )*),
|
||||||
phantom: _serde::__private::PhantomData<#this_type #ty_generics>,
|
phantom: _serde::#private::PhantomData<#this_type #ty_generics>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[automatically_derived]
|
#[automatically_derived]
|
||||||
impl #wrapper_impl_generics _serde::Serialize for __SerializeWith #wrapper_ty_generics #where_clause {
|
impl #wrapper_impl_generics _serde::Serialize for __SerializeWith #wrapper_ty_generics #where_clause {
|
||||||
fn serialize<__S>(&#self_var, #serializer_var: __S) -> _serde::__private::Result<__S::Ok, __S::Error>
|
fn serialize<__S>(&#self_var, #serializer_var: __S) -> _serde::#private::Result<__S::Ok, __S::Error>
|
||||||
where
|
where
|
||||||
__S: _serde::Serializer,
|
__S: _serde::Serializer,
|
||||||
{
|
{
|
||||||
@@ -1252,9 +1255,9 @@ fn wrap_serialize_with(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&__SerializeWith {
|
__SerializeWith {
|
||||||
values: (#(#field_exprs, )*),
|
values: (#(#field_exprs, )*),
|
||||||
phantom: _serde::__private::PhantomData::<#this_type #ty_generics>,
|
phantom: _serde::#private::PhantomData::<#this_type #ty_generics>,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -1290,11 +1293,11 @@ fn get_member(params: &Parameters, field: &Field, member: &Member) -> TokenStrea
|
|||||||
quote!(&#self_var.#member)
|
quote!(&#self_var.#member)
|
||||||
};
|
};
|
||||||
let ty = field.ty;
|
let ty = field.ty;
|
||||||
quote!(_serde::__private::ser::constrain::<#ty>(#inner))
|
quote!(_serde::#private::ser::constrain::<#ty>(#inner))
|
||||||
}
|
}
|
||||||
(true, Some(getter)) => {
|
(true, Some(getter)) => {
|
||||||
let ty = field.ty;
|
let ty = field.ty;
|
||||||
quote!(_serde::__private::ser::constrain::<#ty>(&#getter(#self_var)))
|
quote!(_serde::#private::ser::constrain::<#ty>(&#getter(#self_var)))
|
||||||
}
|
}
|
||||||
(false, Some(_)) => {
|
(false, Some(_)) => {
|
||||||
unreachable!("getter is only allowed for remote impls");
|
unreachable!("getter is only allowed for remote impls");
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
#![deny(deprecated)]
|
||||||
|
#![allow(dead_code)]
|
||||||
|
|
||||||
|
use serde_derive::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize)]
|
||||||
|
#[deprecated]
|
||||||
|
enum DeprecatedEnum {
|
||||||
|
A,
|
||||||
|
B,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize)]
|
||||||
|
#[deprecated]
|
||||||
|
struct DeprecatedStruct {
|
||||||
|
a: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize)]
|
||||||
|
enum DeprecatedVariant {
|
||||||
|
A,
|
||||||
|
#[deprecated]
|
||||||
|
B,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize)]
|
||||||
|
struct DeprecatedField {
|
||||||
|
#[deprecated]
|
||||||
|
a: bool,
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
#![deny(deprecated)]
|
||||||
|
|
||||||
|
use serde::Deserializer;
|
||||||
|
use serde_derive::Deserialize;
|
||||||
|
|
||||||
|
#[derive(Deserialize)]
|
||||||
|
pub struct Struct {
|
||||||
|
#[serde(deserialize_with = "deprecated_with")]
|
||||||
|
pub field: i32,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[deprecated]
|
||||||
|
fn deprecated_with<'de, D>(_deserializer: D) -> Result<i32, D::Error>
|
||||||
|
where
|
||||||
|
D: Deserializer<'de>,
|
||||||
|
{
|
||||||
|
unimplemented!()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
error: use of deprecated function `deprecated_with`
|
||||||
|
--> tests/ui/deprecated/deprecated_de_with.rs:8:32
|
||||||
|
|
|
||||||
|
8 | #[serde(deserialize_with = "deprecated_with")]
|
||||||
|
| ^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
note: the lint level is defined here
|
||||||
|
--> tests/ui/deprecated/deprecated_de_with.rs:1:9
|
||||||
|
|
|
||||||
|
1 | #![deny(deprecated)]
|
||||||
|
| ^^^^^^^^^^
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
#![deny(deprecated)]
|
||||||
|
|
||||||
|
use serde::Serializer;
|
||||||
|
use serde_derive::Serialize;
|
||||||
|
|
||||||
|
#[derive(Serialize)]
|
||||||
|
pub struct Struct {
|
||||||
|
#[serde(serialize_with = "deprecated_with")]
|
||||||
|
pub field: i32,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[deprecated]
|
||||||
|
fn deprecated_with<S>(_field: &i32, _serializer: S) -> Result<S::Ok, S::Error>
|
||||||
|
where
|
||||||
|
S: Serializer,
|
||||||
|
{
|
||||||
|
unimplemented!()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
error: use of deprecated function `deprecated_with`
|
||||||
|
--> tests/ui/deprecated/deprecated_ser_with.rs:8:30
|
||||||
|
|
|
||||||
|
8 | #[serde(serialize_with = "deprecated_with")]
|
||||||
|
| ^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
note: the lint level is defined here
|
||||||
|
--> tests/ui/deprecated/deprecated_ser_with.rs:1:9
|
||||||
|
|
|
||||||
|
1 | #![deny(deprecated)]
|
||||||
|
| ^^^^^^^^^^
|
||||||
@@ -6,10 +6,7 @@ error[E0277]: the trait bound `&u8: serde::Serializer` is not satisfied
|
|||||||
15 | struct W(#[serde(with = "w")] u8, u8);
|
15 | struct W(#[serde(with = "w")] u8, u8);
|
||||||
| --- required by a bound introduced by this call
|
| --- required by a bound introduced by this call
|
||||||
|
|
|
|
||||||
= help: the following other types implement trait `Serializer`:
|
= help: the trait `Serializer` is implemented for `&mut Formatter<'a>`
|
||||||
&mut Formatter<'a>
|
|
||||||
FlatMapSerializer<'a, M>
|
|
||||||
_::_serde::__private::ser::content::ContentSerializer<E>
|
|
||||||
note: required by a bound in `w::serialize`
|
note: required by a bound in `w::serialize`
|
||||||
--> tests/ui/with/incorrect_type.rs:9:28
|
--> tests/ui/with/incorrect_type.rs:9:28
|
||||||
|
|
|
|
||||||
@@ -36,10 +33,7 @@ error[E0277]: the trait bound `&u8: serde::Serializer` is not satisfied
|
|||||||
15 | struct W(#[serde(with = "w")] u8, u8);
|
15 | struct W(#[serde(with = "w")] u8, u8);
|
||||||
| ^^^ the trait `Serializer` is not implemented for `&u8`
|
| ^^^ the trait `Serializer` is not implemented for `&u8`
|
||||||
|
|
|
|
||||||
= help: the following other types implement trait `Serializer`:
|
= help: the trait `Serializer` is implemented for `&mut Formatter<'a>`
|
||||||
&mut Formatter<'a>
|
|
||||||
FlatMapSerializer<'a, M>
|
|
||||||
_::_serde::__private::ser::content::ContentSerializer<E>
|
|
||||||
|
|
||||||
error[E0308]: `?` operator has incompatible types
|
error[E0308]: `?` operator has incompatible types
|
||||||
--> tests/ui/with/incorrect_type.rs:15:25
|
--> tests/ui/with/incorrect_type.rs:15:25
|
||||||
@@ -57,10 +51,7 @@ error[E0277]: the trait bound `&u8: serde::Serializer` is not satisfied
|
|||||||
18 | struct S(#[serde(serialize_with = "w::serialize")] u8, u8);
|
18 | struct S(#[serde(serialize_with = "w::serialize")] u8, u8);
|
||||||
| -------------- required by a bound introduced by this call
|
| -------------- required by a bound introduced by this call
|
||||||
|
|
|
|
||||||
= help: the following other types implement trait `Serializer`:
|
= help: the trait `Serializer` is implemented for `&mut Formatter<'a>`
|
||||||
&mut Formatter<'a>
|
|
||||||
FlatMapSerializer<'a, M>
|
|
||||||
_::_serde::__private::ser::content::ContentSerializer<E>
|
|
||||||
note: required by a bound in `w::serialize`
|
note: required by a bound in `w::serialize`
|
||||||
--> tests/ui/with/incorrect_type.rs:9:28
|
--> tests/ui/with/incorrect_type.rs:9:28
|
||||||
|
|
|
|
||||||
@@ -87,10 +78,7 @@ error[E0277]: the trait bound `&u8: serde::Serializer` is not satisfied
|
|||||||
18 | struct S(#[serde(serialize_with = "w::serialize")] u8, u8);
|
18 | struct S(#[serde(serialize_with = "w::serialize")] u8, u8);
|
||||||
| ^^^^^^^^^^^^^^ the trait `Serializer` is not implemented for `&u8`
|
| ^^^^^^^^^^^^^^ the trait `Serializer` is not implemented for `&u8`
|
||||||
|
|
|
|
||||||
= help: the following other types implement trait `Serializer`:
|
= help: the trait `Serializer` is implemented for `&mut Formatter<'a>`
|
||||||
&mut Formatter<'a>
|
|
||||||
FlatMapSerializer<'a, M>
|
|
||||||
_::_serde::__private::ser::content::ContentSerializer<E>
|
|
||||||
|
|
||||||
error[E0308]: `?` operator has incompatible types
|
error[E0308]: `?` operator has incompatible types
|
||||||
--> tests/ui/with/incorrect_type.rs:21:37
|
--> tests/ui/with/incorrect_type.rs:21:37
|
||||||
|
|||||||
Reference in New Issue
Block a user