mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-06-20 08:01:04 +00:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 7ae1b5f8f3 | |||
| 1ac054b34a | |||
| 1e36ef551d | |||
| 0058c7226e | |||
| 29d4f3e887 |
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "serde"
|
name = "serde"
|
||||||
version = "1.0.211"
|
version = "1.0.212"
|
||||||
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"]
|
||||||
@@ -37,7 +37,7 @@ rustdoc-args = ["--generate-link-to-definition"]
|
|||||||
# 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.211", path = "../serde_derive" }
|
serde_derive = { version = "=1.0.212", path = "../serde_derive" }
|
||||||
|
|
||||||
|
|
||||||
### FEATURES #################################################################
|
### FEATURES #################################################################
|
||||||
|
|||||||
+1
-1
@@ -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.211")]
|
#![doc(html_root_url = "https://docs.rs/serde/1.0.212")]
|
||||||
// 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.
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "serde_derive"
|
name = "serde_derive"
|
||||||
version = "1.0.211"
|
version = "1.0.212"
|
||||||
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)]"
|
||||||
|
|||||||
@@ -2882,13 +2882,14 @@ fn wrap_deserialize_with(
|
|||||||
let (de_impl_generics, de_ty_generics, ty_generics, where_clause) =
|
let (de_impl_generics, de_ty_generics, ty_generics, where_clause) =
|
||||||
split_with_de_lifetime(params);
|
split_with_de_lifetime(params);
|
||||||
let delife = params.borrowed.de_lifetime();
|
let delife = params.borrowed.de_lifetime();
|
||||||
|
let deserializer_var = quote!(__deserializer);
|
||||||
|
|
||||||
// If #deserialize_with returns wrong type, error will be reported here (^^^^^).
|
// If #deserialize_with returns wrong type, error will be reported here (^^^^^).
|
||||||
// We attach span of the path to the function so it will be reported
|
// We attach span of the path to the function so it will be reported
|
||||||
// on the #[serde(with = "...")]
|
// on the #[serde(with = "...")]
|
||||||
// ^^^^^
|
// ^^^^^
|
||||||
let value = quote_spanned! {deserialize_with.span()=>
|
let value = quote_spanned! {deserialize_with.span()=>
|
||||||
#deserialize_with(__deserializer)?
|
#deserialize_with(#deserializer_var)?
|
||||||
};
|
};
|
||||||
let wrapper = quote! {
|
let wrapper = quote! {
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
@@ -2899,7 +2900,7 @@ fn wrap_deserialize_with(
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl #de_impl_generics _serde::Deserialize<#delife> for __DeserializeWith #de_ty_generics #where_clause {
|
impl #de_impl_generics _serde::Deserialize<#delife> for __DeserializeWith #de_ty_generics #where_clause {
|
||||||
fn deserialize<__D>(__deserializer: __D) -> _serde::__private::Result<Self, __D::Error>
|
fn deserialize<__D>(#deserializer_var: __D) -> _serde::__private::Result<Self, __D::Error>
|
||||||
where
|
where
|
||||||
__D: _serde::Deserializer<#delife>,
|
__D: _serde::Deserializer<#delife>,
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -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.211")]
|
#![doc(html_root_url = "https://docs.rs/serde_derive/1.0.212")]
|
||||||
#![cfg_attr(not(check_cfg), allow(unexpected_cfgs))]
|
#![cfg_attr(not(check_cfg), allow(unexpected_cfgs))]
|
||||||
// Ignored clippy lints
|
// Ignored clippy lints
|
||||||
#![allow(
|
#![allow(
|
||||||
|
|||||||
@@ -1220,12 +1220,15 @@ fn wrap_serialize_with(
|
|||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let self_var = quote!(self);
|
||||||
|
let serializer_var = quote!(__s);
|
||||||
|
|
||||||
// If #serialize_with returns wrong type, error will be reported on here.
|
// If #serialize_with returns wrong type, error will be reported on here.
|
||||||
// We attach span of the path to this piece so error will be reported
|
// We attach span of the path to this piece so error will be reported
|
||||||
// on the #[serde(with = "...")]
|
// on the #[serde(with = "...")]
|
||||||
// ^^^^^
|
// ^^^^^
|
||||||
let wrapper_serialize = quote_spanned! {serialize_with.span()=>
|
let wrapper_serialize = quote_spanned! {serialize_with.span()=>
|
||||||
#serialize_with(#(self.values.#field_access, )* __s)
|
#serialize_with(#(#self_var.values.#field_access, )* #serializer_var)
|
||||||
};
|
};
|
||||||
|
|
||||||
quote!({
|
quote!({
|
||||||
@@ -1236,7 +1239,7 @@ fn wrap_serialize_with(
|
|||||||
}
|
}
|
||||||
|
|
||||||
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, __s: __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,
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
use serde_derive::{Serialize, Deserialize};
|
use serde_derive::{Deserialize, Serialize};
|
||||||
use serde_test::{assert_tokens, Token};
|
use serde_test::{assert_tokens, Token};
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug, PartialEq)]
|
#[derive(Serialize, Deserialize, Debug, PartialEq)]
|
||||||
@@ -18,11 +18,15 @@ fn simple_variant() {
|
|||||||
assert_tokens(
|
assert_tokens(
|
||||||
&Enum::Simple { a: 42 },
|
&Enum::Simple { a: 42 },
|
||||||
&[
|
&[
|
||||||
Token::StructVariant { name: "Enum", variant: "Simple", len: 1 },
|
Token::StructVariant {
|
||||||
|
name: "Enum",
|
||||||
|
variant: "Simple",
|
||||||
|
len: 1,
|
||||||
|
},
|
||||||
Token::Str("a"),
|
Token::Str("a"),
|
||||||
Token::I32(42),
|
Token::I32(42),
|
||||||
Token::StructVariantEnd,
|
Token::StructVariantEnd,
|
||||||
]
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -31,11 +35,14 @@ fn flatten_variant() {
|
|||||||
assert_tokens(
|
assert_tokens(
|
||||||
&Enum::Flatten { flatten: (), a: 42 },
|
&Enum::Flatten { flatten: (), a: 42 },
|
||||||
&[
|
&[
|
||||||
Token::NewtypeVariant { name: "Enum", variant: "Flatten" },
|
Token::NewtypeVariant {
|
||||||
|
name: "Enum",
|
||||||
|
variant: "Flatten",
|
||||||
|
},
|
||||||
Token::Map { len: None },
|
Token::Map { len: None },
|
||||||
Token::Str("a"),
|
Token::Str("a"),
|
||||||
Token::I32(42),
|
Token::I32(42),
|
||||||
Token::MapEnd,
|
Token::MapEnd,
|
||||||
]
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
use serde_derive::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
macro_rules! declare_in_macro {
|
||||||
|
($with:literal) => {
|
||||||
|
#[derive(Serialize, Deserialize)]
|
||||||
|
pub struct S {
|
||||||
|
#[serde(with = $with)]
|
||||||
|
f: i32,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
declare_in_macro!("with");
|
||||||
|
|
||||||
|
mod with {
|
||||||
|
use serde::{Deserializer, Serializer};
|
||||||
|
|
||||||
|
pub fn serialize<S>(_: &i32, _: S) -> Result<S::Ok, S::Error>
|
||||||
|
where
|
||||||
|
S: Serializer,
|
||||||
|
{
|
||||||
|
unimplemented!()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn deserialize<'de, D>(_: D) -> Result<i32, D::Error>
|
||||||
|
where
|
||||||
|
D: Deserializer<'de>,
|
||||||
|
{
|
||||||
|
unimplemented!()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -19,8 +19,10 @@ note: required by a bound in `w::serialize`
|
|||||||
error[E0061]: this function takes 1 argument but 2 arguments were supplied
|
error[E0061]: this function takes 1 argument but 2 arguments were supplied
|
||||||
--> tests/ui/with/incorrect_type.rs:15:25
|
--> tests/ui/with/incorrect_type.rs:15:25
|
||||||
|
|
|
|
||||||
|
14 | #[derive(Serialize, Deserialize)]
|
||||||
|
| --------- unexpected argument #2 of type `__S`
|
||||||
15 | struct W(#[serde(with = "w")] u8, u8);
|
15 | struct W(#[serde(with = "w")] u8, u8);
|
||||||
| ^^^ unexpected argument #2 of type `__S`
|
| ^^^
|
||||||
|
|
|
|
||||||
note: function defined here
|
note: function defined here
|
||||||
--> tests/ui/with/incorrect_type.rs:9:12
|
--> tests/ui/with/incorrect_type.rs:9:12
|
||||||
@@ -68,8 +70,10 @@ note: required by a bound in `w::serialize`
|
|||||||
error[E0061]: this function takes 1 argument but 2 arguments were supplied
|
error[E0061]: this function takes 1 argument but 2 arguments were supplied
|
||||||
--> tests/ui/with/incorrect_type.rs:18:35
|
--> tests/ui/with/incorrect_type.rs:18:35
|
||||||
|
|
|
|
||||||
|
17 | #[derive(Serialize, Deserialize)]
|
||||||
|
| --------- unexpected argument #2 of type `__S`
|
||||||
18 | struct S(#[serde(serialize_with = "w::serialize")] u8, u8);
|
18 | struct S(#[serde(serialize_with = "w::serialize")] u8, u8);
|
||||||
| ^^^^^^^^^^^^^^ unexpected argument #2 of type `__S`
|
| ^^^^^^^^^^^^^^
|
||||||
|
|
|
|
||||||
note: function defined here
|
note: function defined here
|
||||||
--> tests/ui/with/incorrect_type.rs:9:12
|
--> tests/ui/with/incorrect_type.rs:9:12
|
||||||
|
|||||||
Reference in New Issue
Block a user