mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-07-04 21:27:23 +00:00
Compare commits
23 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0c6a2bbf79 | |||
| a80d830f27 | |||
| 5f3fd9994e | |||
| d6de911855 | |||
| 04af32230e | |||
| 4cb8d079f8 | |||
| 6ab55a1e52 | |||
| acfd19cb46 | |||
| e3058105f0 | |||
| dc200a6450 | |||
| 2c0999a0b9 | |||
| dd460f82a1 | |||
| c3d637f397 | |||
| 479a00a215 | |||
| c42e7c8012 | |||
| 5b8e0657d4 | |||
| 9fc0d13e2c | |||
| bc22641359 | |||
| 05098105a8 | |||
| 5b23634dc6 | |||
| 32f0d00ff9 | |||
| 9d87851f0c | |||
| c0296ee11b |
@@ -108,12 +108,12 @@ jobs:
|
|||||||
- run: cd serde && cargo build
|
- run: cd serde && cargo build
|
||||||
|
|
||||||
derive:
|
derive:
|
||||||
name: Rust 1.31.0
|
name: Rust 1.56.0
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
timeout-minutes: 45
|
timeout-minutes: 45
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- uses: dtolnay/rust-toolchain@1.31.0
|
- uses: dtolnay/rust-toolchain@1.56.0
|
||||||
- run: cd serde && cargo check --no-default-features
|
- run: cd serde && cargo check --no-default-features
|
||||||
- run: cd serde && cargo check
|
- run: cd serde && cargo check
|
||||||
- run: cd serde_derive && cargo check
|
- run: cd serde_derive && cargo check
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
# Serde   [![Build Status]][actions] [![Latest Version]][crates.io] [![serde: rustc 1.19+]][Rust 1.19] [![serde_derive: rustc 1.31+]][Rust 1.31]
|
# Serde   [![Build Status]][actions] [![Latest Version]][crates.io] [![serde: rustc 1.19+]][Rust 1.19] [![serde_derive: rustc 1.56+]][Rust 1.56]
|
||||||
|
|
||||||
[Build Status]: https://img.shields.io/github/actions/workflow/status/serde-rs/serde/ci.yml?branch=master
|
[Build Status]: https://img.shields.io/github/actions/workflow/status/serde-rs/serde/ci.yml?branch=master
|
||||||
[actions]: https://github.com/serde-rs/serde/actions?query=branch%3Amaster
|
[actions]: https://github.com/serde-rs/serde/actions?query=branch%3Amaster
|
||||||
[Latest Version]: https://img.shields.io/crates/v/serde.svg
|
[Latest Version]: https://img.shields.io/crates/v/serde.svg
|
||||||
[crates.io]: https://crates.io/crates/serde
|
[crates.io]: https://crates.io/crates/serde
|
||||||
[serde: rustc 1.19+]: https://img.shields.io/badge/serde-rustc_1.19+-lightgray.svg
|
[serde: rustc 1.19+]: https://img.shields.io/badge/serde-rustc_1.19+-lightgray.svg
|
||||||
[serde_derive: rustc 1.31+]: https://img.shields.io/badge/serde_derive-rustc_1.31+-lightgray.svg
|
[serde_derive: rustc 1.56+]: https://img.shields.io/badge/serde_derive-rustc_1.56+-lightgray.svg
|
||||||
[Rust 1.19]: https://blog.rust-lang.org/2017/07/20/Rust-1.19.html
|
[Rust 1.19]: https://blog.rust-lang.org/2017/07/20/Rust-1.19.html
|
||||||
[Rust 1.31]: https://blog.rust-lang.org/2018/12/06/Rust-1.31-and-rust-2018.html
|
[Rust 1.56]: https://blog.rust-lang.org/2021/10/21/Rust-1.56.0.html
|
||||||
|
|
||||||
**Serde is a framework for *ser*ializing and *de*serializing Rust data structures efficiently and generically.**
|
**Serde is a framework for *ser*ializing and *de*serializing Rust data structures efficiently and generically.**
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "serde"
|
name = "serde"
|
||||||
version = "1.0.156" # remember to update html_root_url and serde_derive dependency
|
version = "1.0.160" # remember to update html_root_url and serde_derive dependency
|
||||||
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"]
|
categories = ["encoding", "no-std"]
|
||||||
@@ -15,7 +15,7 @@ repository = "https://github.com/serde-rs/serde"
|
|||||||
rust-version = "1.19"
|
rust-version = "1.19"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
serde_derive = { version = "=1.0.156", optional = true, path = "../serde_derive" }
|
serde_derive = { version = "=1.0.160", optional = true, path = "../serde_derive" }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
serde_derive = { version = "1.0", path = "../serde_derive" }
|
serde_derive = { version = "1.0", path = "../serde_derive" }
|
||||||
|
|||||||
+5
-5
@@ -78,11 +78,6 @@ fn main() {
|
|||||||
println!("cargo:rustc-cfg=no_num_nonzero");
|
println!("cargo:rustc-cfg=no_num_nonzero");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Current minimum supported version of serde_derive crate is Rust 1.31.
|
|
||||||
if minor < 31 {
|
|
||||||
println!("cargo:rustc-cfg=no_serde_derive");
|
|
||||||
}
|
|
||||||
|
|
||||||
// TryFrom, Atomic types, non-zero signed integers, and SystemTime::checked_add
|
// TryFrom, Atomic types, non-zero signed integers, and SystemTime::checked_add
|
||||||
// stabilized in Rust 1.34:
|
// stabilized in Rust 1.34:
|
||||||
// https://blog.rust-lang.org/2019/04/11/Rust-1.34.0.html#tryfrom-and-tryinto
|
// https://blog.rust-lang.org/2019/04/11/Rust-1.34.0.html#tryfrom-and-tryinto
|
||||||
@@ -94,6 +89,11 @@ fn main() {
|
|||||||
println!("cargo:rustc-cfg=no_relaxed_trait_bounds");
|
println!("cargo:rustc-cfg=no_relaxed_trait_bounds");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Current minimum supported version of serde_derive crate is Rust 1.56.
|
||||||
|
if minor < 56 {
|
||||||
|
println!("cargo:rustc-cfg=no_serde_derive");
|
||||||
|
}
|
||||||
|
|
||||||
// Support for #[cfg(target_has_atomic = "...")] stabilized in Rust 1.60.
|
// Support for #[cfg(target_has_atomic = "...")] stabilized in Rust 1.60.
|
||||||
if minor < 60 {
|
if minor < 60 {
|
||||||
println!("cargo:rustc-cfg=no_target_has_atomic");
|
println!("cargo:rustc-cfg=no_target_has_atomic");
|
||||||
|
|||||||
+1
-1
@@ -93,7 +93,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.156")]
|
#![doc(html_root_url = "https://docs.rs/serde/1.0.160")]
|
||||||
// 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)]
|
||||||
// Unstable functionality only if the user asks for it. For tracking and
|
// Unstable functionality only if the user asks for it. For tracking and
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "serde_derive"
|
name = "serde_derive"
|
||||||
version = "1.0.156" # remember to update html_root_url
|
version = "1.0.160" # remember to update html_root_url
|
||||||
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"]
|
categories = ["no-std"]
|
||||||
description = "Macros 1.1 implementation of #[derive(Serialize, Deserialize)]"
|
description = "Macros 1.1 implementation of #[derive(Serialize, Deserialize)]"
|
||||||
@@ -11,7 +11,7 @@ keywords = ["serde", "serialization", "no_std", "derive"]
|
|||||||
license = "MIT OR Apache-2.0"
|
license = "MIT OR Apache-2.0"
|
||||||
readme = "crates-io.md"
|
readme = "crates-io.md"
|
||||||
repository = "https://github.com/serde-rs/serde"
|
repository = "https://github.com/serde-rs/serde"
|
||||||
rust-version = "1.31"
|
rust-version = "1.56"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = []
|
default = []
|
||||||
@@ -24,7 +24,7 @@ proc-macro = true
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
proc-macro2 = "1.0"
|
proc-macro2 = "1.0"
|
||||||
quote = "1.0"
|
quote = "1.0"
|
||||||
syn = "1.0.104"
|
syn = "2.0.3"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
serde = { version = "1.0", path = "../serde" }
|
serde = { version = "1.0", path = "../serde" }
|
||||||
|
|||||||
@@ -200,10 +200,16 @@ pub fn with_bound(
|
|||||||
for arg in &arguments.args {
|
for arg in &arguments.args {
|
||||||
match arg {
|
match arg {
|
||||||
syn::GenericArgument::Type(arg) => self.visit_type(arg),
|
syn::GenericArgument::Type(arg) => self.visit_type(arg),
|
||||||
syn::GenericArgument::Binding(arg) => self.visit_type(&arg.ty),
|
syn::GenericArgument::AssocType(arg) => self.visit_type(&arg.ty),
|
||||||
syn::GenericArgument::Lifetime(_)
|
syn::GenericArgument::Lifetime(_)
|
||||||
| syn::GenericArgument::Constraint(_)
|
| syn::GenericArgument::Const(_)
|
||||||
| syn::GenericArgument::Const(_) => {}
|
| syn::GenericArgument::AssocConst(_)
|
||||||
|
| syn::GenericArgument::Constraint(_) => {}
|
||||||
|
#[cfg_attr(
|
||||||
|
all(test, exhaustive),
|
||||||
|
deny(non_exhaustive_omitted_patterns)
|
||||||
|
)]
|
||||||
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -226,7 +232,9 @@ pub fn with_bound(
|
|||||||
fn visit_type_param_bound(&mut self, bound: &'ast syn::TypeParamBound) {
|
fn visit_type_param_bound(&mut self, bound: &'ast syn::TypeParamBound) {
|
||||||
match bound {
|
match bound {
|
||||||
syn::TypeParamBound::Trait(bound) => self.visit_path(&bound.path),
|
syn::TypeParamBound::Trait(bound) => self.visit_path(&bound.path),
|
||||||
syn::TypeParamBound::Lifetime(_) => {}
|
syn::TypeParamBound::Lifetime(_) | syn::TypeParamBound::Verbatim(_) => {}
|
||||||
|
#[cfg_attr(all(test, exhaustive), deny(non_exhaustive_omitted_patterns))]
|
||||||
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -334,7 +342,7 @@ pub fn with_self_bound(
|
|||||||
|
|
||||||
pub fn with_lifetime_bound(generics: &syn::Generics, lifetime: &str) -> syn::Generics {
|
pub fn with_lifetime_bound(generics: &syn::Generics, lifetime: &str) -> syn::Generics {
|
||||||
let bound = syn::Lifetime::new(lifetime, Span::call_site());
|
let bound = syn::Lifetime::new(lifetime, Span::call_site());
|
||||||
let def = syn::LifetimeDef {
|
let def = syn::LifetimeParam {
|
||||||
attrs: Vec::new(),
|
attrs: Vec::new(),
|
||||||
lifetime: bound.clone(),
|
lifetime: bound.clone(),
|
||||||
colon_token: None,
|
colon_token: None,
|
||||||
|
|||||||
+28
-10
@@ -244,9 +244,9 @@ impl BorrowedLifetimes {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn de_lifetime_def(&self) -> Option<syn::LifetimeDef> {
|
fn de_lifetime_param(&self) -> Option<syn::LifetimeParam> {
|
||||||
match self {
|
match self {
|
||||||
BorrowedLifetimes::Borrowed(bounds) => Some(syn::LifetimeDef {
|
BorrowedLifetimes::Borrowed(bounds) => Some(syn::LifetimeParam {
|
||||||
attrs: Vec::new(),
|
attrs: Vec::new(),
|
||||||
lifetime: syn::Lifetime::new("'de", Span::call_site()),
|
lifetime: syn::Lifetime::new("'de", Span::call_site()),
|
||||||
colon_token: None,
|
colon_token: None,
|
||||||
@@ -419,6 +419,7 @@ fn deserialize_unit_struct(params: &Parameters, cattrs: &attr::Container) -> Fra
|
|||||||
let expecting = cattrs.expecting().unwrap_or(&expecting);
|
let expecting = cattrs.expecting().unwrap_or(&expecting);
|
||||||
|
|
||||||
quote_block! {
|
quote_block! {
|
||||||
|
#[doc(hidden)]
|
||||||
struct __Visitor;
|
struct __Visitor;
|
||||||
|
|
||||||
impl<'de> _serde::de::Visitor<'de> for __Visitor {
|
impl<'de> _serde::de::Visitor<'de> for __Visitor {
|
||||||
@@ -515,6 +516,7 @@ fn deserialize_tuple(
|
|||||||
};
|
};
|
||||||
|
|
||||||
quote_block! {
|
quote_block! {
|
||||||
|
#[doc(hidden)]
|
||||||
struct __Visitor #de_impl_generics #where_clause {
|
struct __Visitor #de_impl_generics #where_clause {
|
||||||
marker: _serde::__private::PhantomData<#this_type #ty_generics>,
|
marker: _serde::__private::PhantomData<#this_type #ty_generics>,
|
||||||
lifetime: _serde::__private::PhantomData<&#delife ()>,
|
lifetime: _serde::__private::PhantomData<&#delife ()>,
|
||||||
@@ -605,6 +607,7 @@ fn deserialize_tuple_in_place(
|
|||||||
let place_life = place_lifetime();
|
let place_life = place_lifetime();
|
||||||
|
|
||||||
quote_block! {
|
quote_block! {
|
||||||
|
#[doc(hidden)]
|
||||||
struct __Visitor #in_place_impl_generics #where_clause {
|
struct __Visitor #in_place_impl_generics #where_clause {
|
||||||
place: &#place_life mut #this_type #ty_generics,
|
place: &#place_life mut #this_type #ty_generics,
|
||||||
lifetime: _serde::__private::PhantomData<&#delife ()>,
|
lifetime: _serde::__private::PhantomData<&#delife ()>,
|
||||||
@@ -1020,6 +1023,7 @@ fn deserialize_struct(
|
|||||||
quote_block! {
|
quote_block! {
|
||||||
#field_visitor
|
#field_visitor
|
||||||
|
|
||||||
|
#[doc(hidden)]
|
||||||
struct __Visitor #de_impl_generics #where_clause {
|
struct __Visitor #de_impl_generics #where_clause {
|
||||||
marker: _serde::__private::PhantomData<#this_type #ty_generics>,
|
marker: _serde::__private::PhantomData<#this_type #ty_generics>,
|
||||||
lifetime: _serde::__private::PhantomData<&#delife ()>,
|
lifetime: _serde::__private::PhantomData<&#delife ()>,
|
||||||
@@ -1132,6 +1136,7 @@ fn deserialize_struct_in_place(
|
|||||||
Some(quote_block! {
|
Some(quote_block! {
|
||||||
#field_visitor
|
#field_visitor
|
||||||
|
|
||||||
|
#[doc(hidden)]
|
||||||
struct __Visitor #in_place_impl_generics #where_clause {
|
struct __Visitor #in_place_impl_generics #where_clause {
|
||||||
place: &#place_life mut #this_type #ty_generics,
|
place: &#place_life mut #this_type #ty_generics,
|
||||||
lifetime: _serde::__private::PhantomData<&#delife ()>,
|
lifetime: _serde::__private::PhantomData<&#delife ()>,
|
||||||
@@ -1203,6 +1208,7 @@ fn prepare_enum_variant_enum(
|
|||||||
let variants_stmt = {
|
let variants_stmt = {
|
||||||
let variant_names = variant_names_idents.iter().map(|(name, _, _)| name);
|
let variant_names = variant_names_idents.iter().map(|(name, _, _)| name);
|
||||||
quote! {
|
quote! {
|
||||||
|
#[doc(hidden)]
|
||||||
const VARIANTS: &'static [&'static str] = &[ #(#variant_names),* ];
|
const VARIANTS: &'static [&'static str] = &[ #(#variant_names),* ];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -1275,6 +1281,7 @@ fn deserialize_externally_tagged_enum(
|
|||||||
quote_block! {
|
quote_block! {
|
||||||
#variant_visitor
|
#variant_visitor
|
||||||
|
|
||||||
|
#[doc(hidden)]
|
||||||
struct __Visitor #de_impl_generics #where_clause {
|
struct __Visitor #de_impl_generics #where_clause {
|
||||||
marker: _serde::__private::PhantomData<#this_type #ty_generics>,
|
marker: _serde::__private::PhantomData<#this_type #ty_generics>,
|
||||||
lifetime: _serde::__private::PhantomData<&#delife ()>,
|
lifetime: _serde::__private::PhantomData<&#delife ()>,
|
||||||
@@ -1522,6 +1529,7 @@ fn deserialize_adjacently_tagged_enum(
|
|||||||
|
|
||||||
#variants_stmt
|
#variants_stmt
|
||||||
|
|
||||||
|
#[doc(hidden)]
|
||||||
struct __Seed #de_impl_generics #where_clause {
|
struct __Seed #de_impl_generics #where_clause {
|
||||||
field: __Field,
|
field: __Field,
|
||||||
marker: _serde::__private::PhantomData<#this_type #ty_generics>,
|
marker: _serde::__private::PhantomData<#this_type #ty_generics>,
|
||||||
@@ -1541,6 +1549,7 @@ fn deserialize_adjacently_tagged_enum(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[doc(hidden)]
|
||||||
struct __Visitor #de_impl_generics #where_clause {
|
struct __Visitor #de_impl_generics #where_clause {
|
||||||
marker: _serde::__private::PhantomData<#this_type #ty_generics>,
|
marker: _serde::__private::PhantomData<#this_type #ty_generics>,
|
||||||
lifetime: _serde::__private::PhantomData<&#delife ()>,
|
lifetime: _serde::__private::PhantomData<&#delife ()>,
|
||||||
@@ -1643,6 +1652,7 @@ fn deserialize_adjacently_tagged_enum(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[doc(hidden)]
|
||||||
const FIELDS: &'static [&'static str] = &[#tag, #content];
|
const FIELDS: &'static [&'static str] = &[#tag, #content];
|
||||||
_serde::Deserializer::deserialize_struct(
|
_serde::Deserializer::deserialize_struct(
|
||||||
__deserializer,
|
__deserializer,
|
||||||
@@ -1954,11 +1964,13 @@ fn deserialize_generated_identifier(
|
|||||||
|
|
||||||
quote_block! {
|
quote_block! {
|
||||||
#[allow(non_camel_case_types)]
|
#[allow(non_camel_case_types)]
|
||||||
|
#[doc(hidden)]
|
||||||
enum __Field #lifetime {
|
enum __Field #lifetime {
|
||||||
#(#field_idents,)*
|
#(#field_idents,)*
|
||||||
#ignore_variant
|
#ignore_variant
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[doc(hidden)]
|
||||||
struct __FieldVisitor;
|
struct __FieldVisitor;
|
||||||
|
|
||||||
impl<'de> _serde::de::Visitor<'de> for __FieldVisitor {
|
impl<'de> _serde::de::Visitor<'de> for __FieldVisitor {
|
||||||
@@ -2046,11 +2058,13 @@ fn deserialize_custom_identifier(
|
|||||||
None
|
None
|
||||||
} else if is_variant {
|
} else if is_variant {
|
||||||
let variants = quote! {
|
let variants = quote! {
|
||||||
|
#[doc(hidden)]
|
||||||
const VARIANTS: &'static [&'static str] = &[ #(#names),* ];
|
const VARIANTS: &'static [&'static str] = &[ #(#names),* ];
|
||||||
};
|
};
|
||||||
Some(variants)
|
Some(variants)
|
||||||
} else {
|
} else {
|
||||||
let fields = quote! {
|
let fields = quote! {
|
||||||
|
#[doc(hidden)]
|
||||||
const FIELDS: &'static [&'static str] = &[ #(#names),* ];
|
const FIELDS: &'static [&'static str] = &[ #(#names),* ];
|
||||||
};
|
};
|
||||||
Some(fields)
|
Some(fields)
|
||||||
@@ -2072,6 +2086,7 @@ fn deserialize_custom_identifier(
|
|||||||
quote_block! {
|
quote_block! {
|
||||||
#names_const
|
#names_const
|
||||||
|
|
||||||
|
#[doc(hidden)]
|
||||||
struct __FieldVisitor #de_impl_generics #where_clause {
|
struct __FieldVisitor #de_impl_generics #where_clause {
|
||||||
marker: _serde::__private::PhantomData<#this_type #ty_generics>,
|
marker: _serde::__private::PhantomData<#this_type #ty_generics>,
|
||||||
lifetime: _serde::__private::PhantomData<&#delife ()>,
|
lifetime: _serde::__private::PhantomData<&#delife ()>,
|
||||||
@@ -2406,6 +2421,7 @@ fn deserialize_struct_as_struct_visitor(
|
|||||||
.flat_map(|(_, _, aliases)| aliases);
|
.flat_map(|(_, _, aliases)| aliases);
|
||||||
|
|
||||||
quote_block! {
|
quote_block! {
|
||||||
|
#[doc(hidden)]
|
||||||
const FIELDS: &'static [&'static str] = &[ #(#field_names),* ];
|
const FIELDS: &'static [&'static str] = &[ #(#field_names),* ];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -2684,6 +2700,7 @@ fn deserialize_struct_as_struct_in_place_visitor(
|
|||||||
let fields_stmt = {
|
let fields_stmt = {
|
||||||
let field_names = field_names_idents.iter().map(|(name, _, _)| name);
|
let field_names = field_names_idents.iter().map(|(name, _, _)| name);
|
||||||
quote_block! {
|
quote_block! {
|
||||||
|
#[doc(hidden)]
|
||||||
const FIELDS: &'static [&'static str] = &[ #(#field_names),* ];
|
const FIELDS: &'static [&'static str] = &[ #(#field_names),* ];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -2864,6 +2881,7 @@ fn wrap_deserialize_with(
|
|||||||
let delife = params.borrowed.de_lifetime();
|
let delife = params.borrowed.de_lifetime();
|
||||||
|
|
||||||
let wrapper = quote! {
|
let wrapper = quote! {
|
||||||
|
#[doc(hidden)]
|
||||||
struct __DeserializeWith #de_impl_generics #where_clause {
|
struct __DeserializeWith #de_impl_generics #where_clause {
|
||||||
value: #value_ty,
|
value: #value_ty,
|
||||||
phantom: _serde::__private::PhantomData<#this_type #ty_generics>,
|
phantom: _serde::__private::PhantomData<#this_type #ty_generics>,
|
||||||
@@ -3011,7 +3029,7 @@ struct InPlaceImplGenerics<'a>(&'a Parameters);
|
|||||||
impl<'a> ToTokens for DeImplGenerics<'a> {
|
impl<'a> ToTokens for DeImplGenerics<'a> {
|
||||||
fn to_tokens(&self, tokens: &mut TokenStream) {
|
fn to_tokens(&self, tokens: &mut TokenStream) {
|
||||||
let mut generics = self.0.generics.clone();
|
let mut generics = self.0.generics.clone();
|
||||||
if let Some(de_lifetime) = self.0.borrowed.de_lifetime_def() {
|
if let Some(de_lifetime) = self.0.borrowed.de_lifetime_param() {
|
||||||
generics.params = Some(syn::GenericParam::Lifetime(de_lifetime))
|
generics.params = Some(syn::GenericParam::Lifetime(de_lifetime))
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.chain(generics.params)
|
.chain(generics.params)
|
||||||
@@ -3046,7 +3064,7 @@ impl<'a> ToTokens for InPlaceImplGenerics<'a> {
|
|||||||
.into_iter()
|
.into_iter()
|
||||||
.chain(generics.params)
|
.chain(generics.params)
|
||||||
.collect();
|
.collect();
|
||||||
if let Some(de_lifetime) = self.0.borrowed.de_lifetime_def() {
|
if let Some(de_lifetime) = self.0.borrowed.de_lifetime_param() {
|
||||||
generics.params = Some(syn::GenericParam::Lifetime(de_lifetime))
|
generics.params = Some(syn::GenericParam::Lifetime(de_lifetime))
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.chain(generics.params)
|
.chain(generics.params)
|
||||||
@@ -3071,8 +3089,8 @@ struct InPlaceTypeGenerics<'a>(&'a Parameters);
|
|||||||
impl<'a> ToTokens for DeTypeGenerics<'a> {
|
impl<'a> ToTokens for DeTypeGenerics<'a> {
|
||||||
fn to_tokens(&self, tokens: &mut TokenStream) {
|
fn to_tokens(&self, tokens: &mut TokenStream) {
|
||||||
let mut generics = self.0.generics.clone();
|
let mut generics = self.0.generics.clone();
|
||||||
if self.0.borrowed.de_lifetime_def().is_some() {
|
if self.0.borrowed.de_lifetime_param().is_some() {
|
||||||
let def = syn::LifetimeDef {
|
let def = syn::LifetimeParam {
|
||||||
attrs: Vec::new(),
|
attrs: Vec::new(),
|
||||||
lifetime: syn::Lifetime::new("'de", Span::call_site()),
|
lifetime: syn::Lifetime::new("'de", Span::call_site()),
|
||||||
colon_token: None,
|
colon_token: None,
|
||||||
@@ -3097,8 +3115,8 @@ impl<'a> ToTokens for InPlaceTypeGenerics<'a> {
|
|||||||
.chain(generics.params)
|
.chain(generics.params)
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
if self.0.borrowed.de_lifetime_def().is_some() {
|
if self.0.borrowed.de_lifetime_param().is_some() {
|
||||||
let def = syn::LifetimeDef {
|
let def = syn::LifetimeParam {
|
||||||
attrs: Vec::new(),
|
attrs: Vec::new(),
|
||||||
lifetime: syn::Lifetime::new("'de", Span::call_site()),
|
lifetime: syn::Lifetime::new("'de", Span::call_site()),
|
||||||
colon_token: None,
|
colon_token: None,
|
||||||
@@ -3122,8 +3140,8 @@ impl<'a> DeTypeGenerics<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "deserialize_in_place")]
|
#[cfg(feature = "deserialize_in_place")]
|
||||||
fn place_lifetime() -> syn::LifetimeDef {
|
fn place_lifetime() -> syn::LifetimeParam {
|
||||||
syn::LifetimeDef {
|
syn::LifetimeParam {
|
||||||
attrs: Vec::new(),
|
attrs: Vec::new(),
|
||||||
lifetime: syn::Lifetime::new("'place", Span::call_site()),
|
lifetime: syn::Lifetime::new("'place", Span::call_site()),
|
||||||
colon_token: None,
|
colon_token: None,
|
||||||
|
|||||||
+497
-607
File diff suppressed because it is too large
Load Diff
@@ -3,8 +3,8 @@ use internals::attr::{Identifier, TagType};
|
|||||||
use internals::{ungroup, Ctxt, Derive};
|
use internals::{ungroup, Ctxt, Derive};
|
||||||
use syn::{Member, Type};
|
use syn::{Member, Type};
|
||||||
|
|
||||||
/// Cross-cutting checks that require looking at more than a single attrs
|
// Cross-cutting checks that require looking at more than a single attrs object.
|
||||||
/// object. Simpler checks should happen when parsing and building the attrs.
|
// Simpler checks should happen when parsing and building the attrs.
|
||||||
pub fn check(cx: &Ctxt, cont: &mut Container, derive: Derive) {
|
pub fn check(cx: &Ctxt, cont: &mut Container, derive: Derive) {
|
||||||
check_remote_generic(cx, cont);
|
check_remote_generic(cx, cont);
|
||||||
check_getter(cx, cont);
|
check_getter(cx, cont);
|
||||||
@@ -17,18 +17,18 @@ pub fn check(cx: &Ctxt, cont: &mut Container, derive: Derive) {
|
|||||||
check_from_and_try_from(cx, cont);
|
check_from_and_try_from(cx, cont);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Remote derive definition type must have either all of the generics of the
|
// Remote derive definition type must have either all of the generics of the
|
||||||
/// remote type:
|
// remote type:
|
||||||
///
|
//
|
||||||
/// #[serde(remote = "Generic")]
|
// #[serde(remote = "Generic")]
|
||||||
/// struct Generic<T> {…}
|
// struct Generic<T> {…}
|
||||||
///
|
//
|
||||||
/// or none of them, i.e. defining impls for one concrete instantiation of the
|
// or none of them, i.e. defining impls for one concrete instantiation of the
|
||||||
/// remote type only:
|
// remote type only:
|
||||||
///
|
//
|
||||||
/// #[serde(remote = "Generic<T>")]
|
// #[serde(remote = "Generic<T>")]
|
||||||
/// struct ConcreteDef {…}
|
// struct ConcreteDef {…}
|
||||||
///
|
//
|
||||||
fn check_remote_generic(cx: &Ctxt, cont: &Container) {
|
fn check_remote_generic(cx: &Ctxt, cont: &Container) {
|
||||||
if let Some(remote) = cont.attrs.remote() {
|
if let Some(remote) = cont.attrs.remote() {
|
||||||
let local_has_generic = !cont.generics.params.is_empty();
|
let local_has_generic = !cont.generics.params.is_empty();
|
||||||
@@ -39,8 +39,8 @@ fn check_remote_generic(cx: &Ctxt, cont: &Container) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Getters are only allowed inside structs (not enums) with the `remote`
|
// Getters are only allowed inside structs (not enums) with the `remote`
|
||||||
/// attribute.
|
// attribute.
|
||||||
fn check_getter(cx: &Ctxt, cont: &Container) {
|
fn check_getter(cx: &Ctxt, cont: &Container) {
|
||||||
match cont.data {
|
match cont.data {
|
||||||
Data::Enum(_) => {
|
Data::Enum(_) => {
|
||||||
@@ -62,7 +62,7 @@ fn check_getter(cx: &Ctxt, cont: &Container) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Flattening has some restrictions we can test.
|
// Flattening has some restrictions we can test.
|
||||||
fn check_flatten(cx: &Ctxt, cont: &Container) {
|
fn check_flatten(cx: &Ctxt, cont: &Container) {
|
||||||
match &cont.data {
|
match &cont.data {
|
||||||
Data::Enum(variants) => {
|
Data::Enum(variants) => {
|
||||||
@@ -101,12 +101,12 @@ fn check_flatten_field(cx: &Ctxt, style: Style, field: &Field) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The `other` attribute must be used at most once and it must be the last
|
// The `other` attribute must be used at most once and it must be the last
|
||||||
/// variant of an enum.
|
// variant of an enum.
|
||||||
///
|
//
|
||||||
/// Inside a `variant_identifier` all variants must be unit variants. Inside a
|
// Inside a `variant_identifier` all variants must be unit variants. Inside a
|
||||||
/// `field_identifier` all but possibly one variant must be unit variants. The
|
// `field_identifier` all but possibly one variant must be unit variants. The
|
||||||
/// last variant may be a newtype variant which is an implicit "other" case.
|
// last variant may be a newtype variant which is an implicit "other" case.
|
||||||
fn check_identifier(cx: &Ctxt, cont: &Container) {
|
fn check_identifier(cx: &Ctxt, cont: &Container) {
|
||||||
let variants = match &cont.data {
|
let variants = match &cont.data {
|
||||||
Data::Enum(variants) => variants,
|
Data::Enum(variants) => variants,
|
||||||
@@ -189,8 +189,8 @@ fn check_identifier(cx: &Ctxt, cont: &Container) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Skip-(de)serializing attributes are not allowed on variants marked
|
// Skip-(de)serializing attributes are not allowed on variants marked
|
||||||
/// (de)serialize_with.
|
// (de)serialize_with.
|
||||||
fn check_variant_skip_attrs(cx: &Ctxt, cont: &Container) {
|
fn check_variant_skip_attrs(cx: &Ctxt, cont: &Container) {
|
||||||
let variants = match &cont.data {
|
let variants = match &cont.data {
|
||||||
Data::Enum(variants) => variants,
|
Data::Enum(variants) => variants,
|
||||||
@@ -264,10 +264,9 @@ fn check_variant_skip_attrs(cx: &Ctxt, cont: &Container) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The tag of an internally-tagged struct variant must not be
|
// The tag of an internally-tagged struct variant must not be the same as either
|
||||||
/// the same as either one of its fields, as this would result in
|
// one of its fields, as this would result in duplicate keys in the serialized
|
||||||
/// duplicate keys in the serialized output and/or ambiguity in
|
// output and/or ambiguity in the to-be-deserialized input.
|
||||||
/// the to-be-deserialized input.
|
|
||||||
fn check_internal_tag_field_name_conflict(cx: &Ctxt, cont: &Container) {
|
fn check_internal_tag_field_name_conflict(cx: &Ctxt, cont: &Container) {
|
||||||
let variants = match &cont.data {
|
let variants = match &cont.data {
|
||||||
Data::Enum(variants) => variants,
|
Data::Enum(variants) => variants,
|
||||||
@@ -313,8 +312,8 @@ fn check_internal_tag_field_name_conflict(cx: &Ctxt, cont: &Container) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// In the case of adjacently-tagged enums, the type and the
|
// In the case of adjacently-tagged enums, the type and the contents tag must
|
||||||
/// contents tag must differ, for the same reason.
|
// differ, for the same reason.
|
||||||
fn check_adjacent_tag_conflict(cx: &Ctxt, cont: &Container) {
|
fn check_adjacent_tag_conflict(cx: &Ctxt, cont: &Container) {
|
||||||
let (type_tag, content_tag) = match cont.attrs.tag() {
|
let (type_tag, content_tag) = match cont.attrs.tag() {
|
||||||
TagType::Adjacent { tag, content } => (tag, content),
|
TagType::Adjacent { tag, content } => (tag, content),
|
||||||
@@ -332,7 +331,7 @@ fn check_adjacent_tag_conflict(cx: &Ctxt, cont: &Container) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Enums and unit structs cannot be transparent.
|
// Enums and unit structs cannot be transparent.
|
||||||
fn check_transparent(cx: &Ctxt, cont: &mut Container, derive: Derive) {
|
fn check_transparent(cx: &Ctxt, cont: &mut Container, derive: Derive) {
|
||||||
if !cont.attrs.transparent() {
|
if !cont.attrs.transparent() {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -179,10 +179,13 @@ impl ReplaceReceiver<'_> {
|
|||||||
for arg in &mut arguments.args {
|
for arg in &mut arguments.args {
|
||||||
match arg {
|
match arg {
|
||||||
GenericArgument::Type(arg) => self.visit_type_mut(arg),
|
GenericArgument::Type(arg) => self.visit_type_mut(arg),
|
||||||
GenericArgument::Binding(arg) => self.visit_type_mut(&mut arg.ty),
|
GenericArgument::AssocType(arg) => self.visit_type_mut(&mut arg.ty),
|
||||||
GenericArgument::Lifetime(_)
|
GenericArgument::Lifetime(_)
|
||||||
| GenericArgument::Constraint(_)
|
| GenericArgument::Const(_)
|
||||||
| GenericArgument::Const(_) => {}
|
| GenericArgument::AssocConst(_)
|
||||||
|
| GenericArgument::Constraint(_) => {}
|
||||||
|
#[cfg_attr(all(test, exhaustive), deny(non_exhaustive_omitted_patterns))]
|
||||||
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -205,7 +208,9 @@ impl ReplaceReceiver<'_> {
|
|||||||
fn visit_type_param_bound_mut(&mut self, bound: &mut TypeParamBound) {
|
fn visit_type_param_bound_mut(&mut self, bound: &mut TypeParamBound) {
|
||||||
match bound {
|
match bound {
|
||||||
TypeParamBound::Trait(bound) => self.visit_path_mut(&mut bound.path),
|
TypeParamBound::Trait(bound) => self.visit_path_mut(&mut bound.path),
|
||||||
TypeParamBound::Lifetime(_) => {}
|
TypeParamBound::Lifetime(_) | TypeParamBound::Verbatim(_) => {}
|
||||||
|
#[cfg_attr(all(test, exhaustive), deny(non_exhaustive_omitted_patterns))]
|
||||||
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -229,7 +234,9 @@ impl ReplaceReceiver<'_> {
|
|||||||
self.visit_type_param_bound_mut(bound);
|
self.visit_type_param_bound_mut(bound);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
WherePredicate::Lifetime(_) | WherePredicate::Eq(_) => {}
|
WherePredicate::Lifetime(_) => {}
|
||||||
|
#[cfg_attr(all(test, exhaustive), deny(non_exhaustive_omitted_patterns))]
|
||||||
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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.156")]
|
#![doc(html_root_url = "https://docs.rs/serde_derive/1.0.160")]
|
||||||
#![allow(unknown_lints, bare_trait_objects)]
|
#![allow(unknown_lints, bare_trait_objects)]
|
||||||
// Ignored clippy lints
|
// Ignored clippy lints
|
||||||
#![allow(
|
#![allow(
|
||||||
|
|||||||
@@ -719,6 +719,7 @@ fn serialize_adjacently_tagged_variant(
|
|||||||
let (wrapper_impl_generics, wrapper_ty_generics, _) = wrapper_generics.split_for_impl();
|
let (wrapper_impl_generics, wrapper_ty_generics, _) = wrapper_generics.split_for_impl();
|
||||||
|
|
||||||
quote_block! {
|
quote_block! {
|
||||||
|
#[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>,
|
||||||
@@ -982,6 +983,7 @@ fn serialize_struct_variant_with_flatten(
|
|||||||
let (wrapper_impl_generics, wrapper_ty_generics, _) = wrapper_generics.split_for_impl();
|
let (wrapper_impl_generics, wrapper_ty_generics, _) = wrapper_generics.split_for_impl();
|
||||||
|
|
||||||
quote_block! {
|
quote_block! {
|
||||||
|
#[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>,
|
||||||
@@ -1212,6 +1214,7 @@ fn wrap_serialize_with(
|
|||||||
});
|
});
|
||||||
|
|
||||||
quote!({
|
quote!({
|
||||||
|
#[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>,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "serde_derive_internals"
|
name = "serde_derive_internals"
|
||||||
version = "0.26.0" # remember to update html_root_url
|
version = "0.27.0" # remember to update html_root_url
|
||||||
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>", "David Tolnay <dtolnay@gmail.com>"]
|
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>", "David Tolnay <dtolnay@gmail.com>"]
|
||||||
description = "AST representation used by Serde derive macros. Unstable."
|
description = "AST representation used by Serde derive macros. Unstable."
|
||||||
documentation = "https://docs.rs/serde_derive_internals"
|
documentation = "https://docs.rs/serde_derive_internals"
|
||||||
@@ -9,7 +9,7 @@ include = ["lib.rs", "src/**/*.rs", "LICENSE-APACHE", "LICENSE-MIT"]
|
|||||||
keywords = ["serde", "serialization"]
|
keywords = ["serde", "serialization"]
|
||||||
license = "MIT OR Apache-2.0"
|
license = "MIT OR Apache-2.0"
|
||||||
repository = "https://github.com/serde-rs/serde"
|
repository = "https://github.com/serde-rs/serde"
|
||||||
rust-version = "1.31"
|
rust-version = "1.56"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
path = "lib.rs"
|
path = "lib.rs"
|
||||||
@@ -17,7 +17,7 @@ path = "lib.rs"
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
proc-macro2 = "1.0"
|
proc-macro2 = "1.0"
|
||||||
quote = "1.0"
|
quote = "1.0"
|
||||||
syn = { version = "1.0.104", default-features = false, features = ["derive", "parsing", "printing", "clone-impls"] }
|
syn = { version = "2.0", default-features = false, features = ["derive", "parsing", "printing", "clone-impls"] }
|
||||||
|
|
||||||
[package.metadata.docs.rs]
|
[package.metadata.docs.rs]
|
||||||
targets = ["x86_64-unknown-linux-gnu"]
|
targets = ["x86_64-unknown-linux-gnu"]
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#![doc(html_root_url = "https://docs.rs/serde_derive_internals/0.26.0")]
|
#![doc(html_root_url = "https://docs.rs/serde_derive_internals/0.27.0")]
|
||||||
#![allow(unknown_lints, bare_trait_objects)]
|
#![allow(unknown_lints, bare_trait_objects)]
|
||||||
// Ignored clippy lints
|
// Ignored clippy lints
|
||||||
#![allow(
|
#![allow(
|
||||||
@@ -31,6 +31,7 @@
|
|||||||
clippy::module_name_repetitions,
|
clippy::module_name_repetitions,
|
||||||
clippy::must_use_candidate,
|
clippy::must_use_candidate,
|
||||||
clippy::similar_names,
|
clippy::similar_names,
|
||||||
|
clippy::single_match_else,
|
||||||
clippy::struct_excessive_bools,
|
clippy::struct_excessive_bools,
|
||||||
clippy::too_many_lines,
|
clippy::too_many_lines,
|
||||||
clippy::unused_self,
|
clippy::unused_self,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "serde_test"
|
name = "serde_test"
|
||||||
version = "1.0.156" # remember to update html_root_url
|
version = "1.0.160" # remember to update html_root_url
|
||||||
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 = ["development-tools::testing"]
|
categories = ["development-tools::testing"]
|
||||||
|
|||||||
@@ -140,7 +140,7 @@
|
|||||||
//! # }
|
//! # }
|
||||||
//! ```
|
//! ```
|
||||||
|
|
||||||
#![doc(html_root_url = "https://docs.rs/serde_test/1.0.156")]
|
#![doc(html_root_url = "https://docs.rs/serde_test/1.0.160")]
|
||||||
#![cfg_attr(feature = "cargo-clippy", allow(renamed_and_removed_lints))]
|
#![cfg_attr(feature = "cargo-clippy", allow(renamed_and_removed_lints))]
|
||||||
// Ignored clippy lints
|
// Ignored clippy lints
|
||||||
#![cfg_attr(feature = "cargo-clippy", allow(float_cmp, needless_doctest_main))]
|
#![cfg_attr(feature = "cargo-clippy", allow(float_cmp, needless_doctest_main))]
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
use serde::Deserialize;
|
||||||
|
|
||||||
|
macro_rules! bug {
|
||||||
|
($serde_path:literal) => {
|
||||||
|
#[derive(Deserialize)]
|
||||||
|
#[serde(crate = $serde_path)]
|
||||||
|
pub struct Struct;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
bug!("serde");
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
use serde_derive::Serialize;
|
||||||
|
|
||||||
|
#[derive(Serialize)]
|
||||||
|
#[serde()]
|
||||||
|
pub struct S;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
error: unexpected end of input, expected literal
|
error: unexpected end of input, expected an expression
|
||||||
--> tests/ui/malformed/cut_off.rs:4:17
|
--> tests/ui/malformed/cut_off.rs:4:17
|
||||||
|
|
|
|
||||||
4 | #[serde(rename =)]
|
4 | #[serde(rename =)]
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
error: expected #[serde(...)]
|
error: expected attribute arguments in parentheses: #[serde(...)]
|
||||||
--> tests/ui/malformed/not_list.rs:4:3
|
--> tests/ui/malformed/not_list.rs:4:3
|
||||||
|
|
|
|
||||||
4 | #[serde]
|
4 | #[serde]
|
||||||
| ^^^^^
|
| ^^^^^
|
||||||
|
|
||||||
error: expected #[serde(...)]
|
error: expected parentheses: #[serde(...)]
|
||||||
--> tests/ui/malformed/not_list.rs:5:3
|
--> tests/ui/malformed/not_list.rs:5:9
|
||||||
|
|
|
|
||||||
5 | #[serde = "?"]
|
5 | #[serde = "?"]
|
||||||
| ^^^^^^^^^^^
|
| ^
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
use serde_derive::Serialize;
|
||||||
|
|
||||||
|
#[derive(Serialize)]
|
||||||
|
struct S {
|
||||||
|
#[serde(skip_serializing_if, x.is_empty())]
|
||||||
|
x: Vec<()>,
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
error: expected `=`
|
||||||
|
--> tests/ui/malformed/trailing_expr.rs:5:32
|
||||||
|
|
|
||||||
|
5 | #[serde(skip_serializing_if, x.is_empty())]
|
||||||
|
| ^
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
error: unexpected literal in serde container attribute
|
error: unexpected literal in nested attribute, expected ident
|
||||||
--> tests/ui/unexpected-literal/container.rs:4:9
|
--> tests/ui/unexpected-literal/container.rs:4:9
|
||||||
|
|
|
|
||||||
4 | #[serde("literal")]
|
4 | #[serde("literal")]
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
error: unexpected literal in serde field attribute
|
error: unexpected literal in nested attribute, expected ident
|
||||||
--> tests/ui/unexpected-literal/field.rs:5:13
|
--> tests/ui/unexpected-literal/field.rs:5:13
|
||||||
|
|
|
|
||||||
5 | #[serde("literal")]
|
5 | #[serde("literal")]
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
error: unexpected literal in serde variant attribute
|
error: unexpected literal in nested attribute, expected ident
|
||||||
--> tests/ui/unexpected-literal/variant.rs:5:13
|
--> tests/ui/unexpected-literal/variant.rs:5:13
|
||||||
|
|
|
|
||||||
5 | #[serde("literal")]
|
5 | #[serde("literal")]
|
||||||
|
|||||||
Reference in New Issue
Block a user