mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-04-23 02:28:00 +00:00
Compare commits
60 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 77ae1c3bf7 | |||
| b85e28166c | |||
| 0508cb50fc | |||
| 84fdc7df69 | |||
| ab1ca04b2e | |||
| fb2fe409c8 | |||
| 549fac7235 | |||
| c375d8b19b | |||
| 6cf507f808 | |||
| c3c1641c06 | |||
| 1fcda0ebdb | |||
| 8f16ac0a94 | |||
| 737f78c315 | |||
| 4a97386cb9 | |||
| 5b32217877 | |||
| 5b140361a3 | |||
| 678351eac7 | |||
| 999c261d11 | |||
| efbe574209 | |||
| 33b2677384 | |||
| 01ded9f405 | |||
| fc827ecec2 | |||
| 5c785eee58 | |||
| 819db93a3d | |||
| a6690ea2fe | |||
| 65e1a50749 | |||
| 87d41b59fd | |||
| 3f120fb355 | |||
| 2b92c80cc1 | |||
| c1c0ede452 | |||
| 4a66c5f33d | |||
| 714c8a5586 | |||
| dc0c0dcba1 | |||
| 54102ee7d0 | |||
| 14accf7518 | |||
| 55fdbea20b | |||
| 75d8902371 | |||
| 9451ea8df1 | |||
| c1ce03b3dd | |||
| a587eb8953 | |||
| 990f7eb6c1 | |||
| 082e18f9a1 | |||
| f309485787 | |||
| e2f85681fe | |||
| 8b840c3030 | |||
| 9c39115f82 | |||
| 89342af71e | |||
| 3c5e2d11f6 | |||
| 3805c037a8 | |||
| 7045fee260 | |||
| 9d81532e41 | |||
| 5e47432ef0 | |||
| e0fc46783d | |||
| ca772a14f9 | |||
| 7b840897a9 | |||
| 967795414b | |||
| 985725f820 | |||
| 0c303d85d7 | |||
| f68e9e901e | |||
| 1094e2d334 |
@@ -153,11 +153,9 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: dtolnay/rust-toolchain@clippy
|
||||
# The need for -Aredundant_field_names here is a Clippy bug.
|
||||
# https://github.com/rust-lang/rust-clippy/issues/5356
|
||||
- run: cd serde && cargo clippy --features rc,unstable -- -D clippy::all -A clippy::redundant_field_names
|
||||
- run: cd serde_derive && cargo clippy -- -D clippy::all
|
||||
- run: cd serde_derive_internals && cargo clippy -- -D clippy::all
|
||||
- run: cd serde_test && cargo clippy -- -D clippy::all -A clippy::redundant_field_names
|
||||
- run: cd test_suite && cargo clippy --tests --features unstable -- -D clippy::all -A clippy::redundant_field_names
|
||||
- run: cd test_suite/no_std && cargo clippy -- -D clippy::all -A clippy::redundant_field_names
|
||||
- run: cd serde && cargo clippy --features rc,unstable -- -Dclippy::all -Dclippy::pedantic
|
||||
- run: cd serde_derive && cargo clippy -- -Dclippy::all -Dclippy::pedantic
|
||||
- run: cd serde_derive_internals && cargo clippy -- -Dclippy::all -Dclippy::pedantic
|
||||
- run: cd serde_test && cargo clippy -- -Dclippy::all -Dclippy::pedantic
|
||||
- run: cd test_suite && cargo clippy --tests --features unstable -- -Dclippy::all -Dclippy::pedantic
|
||||
- run: cd test_suite/no_std && cargo clippy -- -Dclippy::all -Dclippy::pedantic
|
||||
|
||||
+4
-10
@@ -31,25 +31,19 @@ tests for you.
|
||||
|
||||
```sh
|
||||
# Test all the example code in Serde documentation
|
||||
cargo test
|
||||
```
|
||||
|
||||
##### In the [`test_suite/deps`] directory
|
||||
|
||||
```sh
|
||||
# This is a prerequisite for running the full test suite
|
||||
cargo clean && cargo update && cargo build
|
||||
cargo test --features derive
|
||||
```
|
||||
|
||||
##### In the [`test_suite`] directory
|
||||
|
||||
```sh
|
||||
# Run the full test suite, including tests of unstable functionality
|
||||
cargo test --features unstable
|
||||
cargo +nightly test --features unstable
|
||||
```
|
||||
|
||||
Note that this test suite currently only supports running on a nightly compiler.
|
||||
|
||||
[`serde`]: https://github.com/serde-rs/serde/tree/master/serde
|
||||
[`test_suite/deps`]: https://github.com/serde-rs/serde/tree/master/test_suite/deps
|
||||
[`test_suite`]: https://github.com/serde-rs/serde/tree/master/test_suite
|
||||
|
||||
## Conduct
|
||||
|
||||
+3
-2
@@ -1,7 +1,8 @@
|
||||
[package]
|
||||
name = "serde"
|
||||
version = "1.0.126" # remember to update html_root_url and serde_derive dependency
|
||||
version = "1.0.132" # remember to update html_root_url and serde_derive dependency
|
||||
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>", "David Tolnay <dtolnay@gmail.com>"]
|
||||
rust-version = "1.15"
|
||||
license = "MIT OR Apache-2.0"
|
||||
description = "A generic serialization/deserialization framework"
|
||||
homepage = "https://serde.rs"
|
||||
@@ -14,7 +15,7 @@ include = ["build.rs", "src/**/*.rs", "crates-io.md", "README.md", "LICENSE-APAC
|
||||
build = "build.rs"
|
||||
|
||||
[dependencies]
|
||||
serde_derive = { version = "=1.0.126", optional = true, path = "../serde_derive" }
|
||||
serde_derive = { version = "=1.0.132", optional = true, path = "../serde_derive" }
|
||||
|
||||
[dev-dependencies]
|
||||
serde_derive = { version = "1.0", path = "../serde_derive" }
|
||||
|
||||
+10
-5
@@ -53,16 +53,20 @@ fn main() {
|
||||
// 128-bit integers stabilized in Rust 1.26:
|
||||
// https://blog.rust-lang.org/2018/05/10/Rust-1.26.html
|
||||
//
|
||||
// Disabled on Emscripten targets as Emscripten doesn't
|
||||
// currently support integers larger than 64 bits.
|
||||
if minor >= 26 && !emscripten {
|
||||
// Disabled on Emscripten targets before Rust 1.40 since
|
||||
// Emscripten did not support 128-bit integers until Rust 1.40
|
||||
// (https://github.com/rust-lang/rust/pull/65251)
|
||||
if minor >= 26 && (!emscripten || minor >= 40) {
|
||||
println!("cargo:rustc-cfg=integer128");
|
||||
}
|
||||
|
||||
// Inclusive ranges methods stabilized in Rust 1.27:
|
||||
// https://github.com/rust-lang/rust/pull/50758
|
||||
// Also Iterator::try_for_each:
|
||||
// https://blog.rust-lang.org/2018/06/21/Rust-1.27.html#library-stabilizations
|
||||
if minor >= 27 {
|
||||
println!("cargo:rustc-cfg=range_inclusive");
|
||||
println!("cargo:rustc-cfg=iterator_try_fold");
|
||||
}
|
||||
|
||||
// Non-zero integers stabilized in Rust 1.28:
|
||||
@@ -87,13 +91,14 @@ fn main() {
|
||||
|
||||
// Whitelist of archs that support std::sync::atomic module. Ideally we
|
||||
// would use #[cfg(target_has_atomic = "...")] but it is not stable yet.
|
||||
// Instead this is based on rustc's src/librustc_target/spec/*.rs.
|
||||
// Instead this is based on rustc's compiler/rustc_target/src/spec/*.rs.
|
||||
let has_atomic64 = target.starts_with("x86_64")
|
||||
|| target.starts_with("i686")
|
||||
|| target.starts_with("aarch64")
|
||||
|| target.starts_with("powerpc64")
|
||||
|| target.starts_with("sparc64")
|
||||
|| target.starts_with("mips64el");
|
||||
|| target.starts_with("mips64el")
|
||||
|| target.starts_with("riscv64");
|
||||
let has_atomic32 = has_atomic64 || emscripten;
|
||||
if has_atomic64 {
|
||||
println!("cargo:rustc-cfg=std_atomic64");
|
||||
|
||||
+3
-3
@@ -1007,7 +1007,7 @@ pub trait Deserializer<'de>: Sized {
|
||||
/// `Deserializer`.
|
||||
///
|
||||
/// If the `Visitor` would benefit from taking ownership of `String` data,
|
||||
/// indiciate this to the `Deserializer` by using `deserialize_string`
|
||||
/// indicate this to the `Deserializer` by using `deserialize_string`
|
||||
/// instead.
|
||||
fn deserialize_str<V>(self, visitor: V) -> Result<V::Value, Self::Error>
|
||||
where
|
||||
@@ -1714,7 +1714,7 @@ pub trait SeqAccess<'de> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'de, 'a, A> SeqAccess<'de> for &'a mut A
|
||||
impl<'de, 'a, A: ?Sized> SeqAccess<'de> for &'a mut A
|
||||
where
|
||||
A: SeqAccess<'de>,
|
||||
{
|
||||
@@ -1867,7 +1867,7 @@ pub trait MapAccess<'de> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'de, 'a, A> MapAccess<'de> for &'a mut A
|
||||
impl<'de, 'a, A: ?Sized> MapAccess<'de> for &'a mut A
|
||||
where
|
||||
A: MapAccess<'de>,
|
||||
{
|
||||
|
||||
+6
-5
@@ -60,7 +60,7 @@
|
||||
//!
|
||||
//! [JSON]: https://github.com/serde-rs/json
|
||||
//! [Bincode]: https://github.com/servo/bincode
|
||||
//! [CBOR]: https://github.com/pyfisch/cbor
|
||||
//! [CBOR]: https://github.com/enarx/ciborium
|
||||
//! [YAML]: https://github.com/dtolnay/serde-yaml
|
||||
//! [MessagePack]: https://github.com/3Hren/msgpack-rust
|
||||
//! [TOML]: https://github.com/alexcrichton/toml-rs
|
||||
@@ -73,7 +73,7 @@
|
||||
//! [URL]: https://docs.rs/serde_qs
|
||||
//! [Envy]: https://github.com/softprops/envy
|
||||
//! [Envy Store]: https://github.com/softprops/envy-store
|
||||
//! [Cargo]: http://doc.crates.io/manifest.html
|
||||
//! [Cargo]: https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
//! [AWS Parameter Store]: https://docs.aws.amazon.com/systems-manager/latest/userguide/systems-manager-paramstore.html
|
||||
//! [S-expressions]: https://github.com/rotty/lexpr-rs
|
||||
//! [D-Bus]: https://docs.rs/zvariant
|
||||
@@ -84,7 +84,7 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Serde types in rustdoc of other crates get linked to here.
|
||||
#![doc(html_root_url = "https://docs.rs/serde/1.0.126")]
|
||||
#![doc(html_root_url = "https://docs.rs/serde/1.0.132")]
|
||||
// Support using Serde without the standard library!
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
// Unstable functionality only if the user asks for it. For tracking and
|
||||
@@ -94,13 +94,14 @@
|
||||
#![cfg_attr(feature = "unstable", feature(never_type))]
|
||||
#![allow(unknown_lints, bare_trait_objects, deprecated)]
|
||||
#![cfg_attr(feature = "cargo-clippy", allow(renamed_and_removed_lints))]
|
||||
#![cfg_attr(feature = "cargo-clippy", deny(clippy, clippy_pedantic))]
|
||||
// Ignored clippy and clippy_pedantic lints
|
||||
#![cfg_attr(
|
||||
feature = "cargo-clippy",
|
||||
allow(
|
||||
// clippy bug: https://github.com/rust-lang/rust-clippy/issues/5704
|
||||
unnested_or_patterns,
|
||||
// clippy bug: https://github.com/rust-lang/rust-clippy/issues/7768
|
||||
semicolon_if_nothing_returned,
|
||||
// not available in our oldest supported compiler
|
||||
checked_conversions,
|
||||
empty_enum,
|
||||
@@ -157,7 +158,7 @@ mod lib {
|
||||
pub use std::*;
|
||||
}
|
||||
|
||||
pub use self::core::{cmp, iter, mem, num, slice, str};
|
||||
pub use self::core::{cmp, iter, mem, num, ptr, slice, str};
|
||||
pub use self::core::{f32, f64};
|
||||
pub use self::core::{i16, i32, i64, i8, isize};
|
||||
pub use self::core::{u16, u32, u64, u8, usize};
|
||||
|
||||
@@ -2832,7 +2832,7 @@ where
|
||||
where
|
||||
T: DeserializeSeed<'de>,
|
||||
{
|
||||
while let Some(item) = self.iter.next() {
|
||||
for item in &mut self.iter {
|
||||
// Items in the vector are nulled out when used by a struct.
|
||||
if let Some((ref key, ref content)) = *item {
|
||||
self.pending_content = Some(content);
|
||||
@@ -2934,7 +2934,7 @@ where
|
||||
where
|
||||
T: DeserializeSeed<'de>,
|
||||
{
|
||||
while let Some(item) = self.iter.next() {
|
||||
for item in &mut self.iter {
|
||||
if let Some((ref key, ref content)) = *item {
|
||||
// Do not take(), instead borrow this entry. The internally tagged
|
||||
// enum does its own buffering so we can't tell whether this entry
|
||||
|
||||
@@ -14,6 +14,7 @@ pub use lib::default::Default;
|
||||
pub use lib::fmt::{self, Formatter};
|
||||
pub use lib::marker::PhantomData;
|
||||
pub use lib::option::Option::{self, None, Some};
|
||||
pub use lib::ptr;
|
||||
pub use lib::result::Result::{self, Err, Ok};
|
||||
|
||||
pub use self::string::from_utf8_lossy;
|
||||
|
||||
+26
-4
@@ -1279,9 +1279,20 @@ pub trait Serializer: Sized {
|
||||
{
|
||||
let iter = iter.into_iter();
|
||||
let mut serializer = try!(self.serialize_seq(iterator_len_hint(&iter)));
|
||||
for item in iter {
|
||||
try!(serializer.serialize_element(&item));
|
||||
|
||||
#[cfg(iterator_try_fold)]
|
||||
{
|
||||
let mut iter = iter;
|
||||
try!(iter.try_for_each(|item| serializer.serialize_element(&item)));
|
||||
}
|
||||
|
||||
#[cfg(not(iterator_try_fold))]
|
||||
{
|
||||
for item in iter {
|
||||
try!(serializer.serialize_element(&item));
|
||||
}
|
||||
}
|
||||
|
||||
serializer.end()
|
||||
}
|
||||
|
||||
@@ -1319,9 +1330,20 @@ pub trait Serializer: Sized {
|
||||
{
|
||||
let iter = iter.into_iter();
|
||||
let mut serializer = try!(self.serialize_map(iterator_len_hint(&iter)));
|
||||
for (key, value) in iter {
|
||||
try!(serializer.serialize_entry(&key, &value));
|
||||
|
||||
#[cfg(iterator_try_fold)]
|
||||
{
|
||||
let mut iter = iter;
|
||||
try!(iter.try_for_each(|(key, value)| serializer.serialize_entry(&key, &value)));
|
||||
}
|
||||
|
||||
#[cfg(not(iterator_try_fold))]
|
||||
{
|
||||
for (key, value) in iter {
|
||||
try!(serializer.serialize_entry(&key, &value));
|
||||
}
|
||||
}
|
||||
|
||||
serializer.end()
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
[package]
|
||||
name = "serde_derive"
|
||||
version = "1.0.126" # remember to update html_root_url
|
||||
version = "1.0.132" # remember to update html_root_url
|
||||
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>", "David Tolnay <dtolnay@gmail.com>"]
|
||||
rust-version = "1.31"
|
||||
license = "MIT OR Apache-2.0"
|
||||
description = "Macros 1.1 implementation of #[derive(Serialize, Deserialize)]"
|
||||
homepage = "https://serde.rs"
|
||||
|
||||
@@ -16,6 +16,12 @@ fn main() {
|
||||
if minor >= 37 {
|
||||
println!("cargo:rustc-cfg=underscore_consts");
|
||||
}
|
||||
|
||||
// The ptr::addr_of! macro stabilized in Rust 1.51:
|
||||
// https://blog.rust-lang.org/2021/03/25/Rust-1.51.0.html#stabilized-apis
|
||||
if minor >= 51 {
|
||||
println!("cargo:rustc-cfg=ptr_addr_of");
|
||||
}
|
||||
}
|
||||
|
||||
fn rustc_minor_version() -> Option<u32> {
|
||||
|
||||
@@ -50,7 +50,7 @@ pub fn with_where_predicates_from_fields(
|
||||
.data
|
||||
.all_fields()
|
||||
.filter_map(|field| from_field(&field.attrs))
|
||||
.flat_map(|predicates| predicates.to_vec());
|
||||
.flat_map(<[syn::WherePredicate]>::to_vec);
|
||||
|
||||
let mut generics = generics.clone();
|
||||
generics.make_where_clause().predicates.extend(predicates);
|
||||
@@ -72,7 +72,7 @@ pub fn with_where_predicates_from_variants(
|
||||
let predicates = variants
|
||||
.iter()
|
||||
.filter_map(|variant| from_variant(&variant.attrs))
|
||||
.flat_map(|predicates| predicates.to_vec());
|
||||
.flat_map(<[syn::WherePredicate]>::to_vec);
|
||||
|
||||
let mut generics = generics.clone();
|
||||
generics.make_where_clause().predicates.extend(predicates);
|
||||
|
||||
+46
-24
@@ -36,7 +36,7 @@ pub fn expand_derive_deserialize(
|
||||
|
||||
let impl_block = if let Some(remote) = cont.attrs.remote() {
|
||||
let vis = &input.vis;
|
||||
let used = pretend::pretend_used(&cont);
|
||||
let used = pretend::pretend_used(&cont, params.is_packed);
|
||||
quote! {
|
||||
impl #de_impl_generics #ident #ty_generics #where_clause {
|
||||
#vis fn deserialize<__D>(__deserializer: __D) -> #serde::__private::Result<#remote #ty_generics, __D::Error>
|
||||
@@ -125,6 +125,9 @@ struct Parameters {
|
||||
/// At least one field has a serde(getter) attribute, implying that the
|
||||
/// remote type has a private field.
|
||||
has_getter: bool,
|
||||
|
||||
/// Type has a repr(packed) attribute.
|
||||
is_packed: bool,
|
||||
}
|
||||
|
||||
impl Parameters {
|
||||
@@ -137,6 +140,7 @@ impl Parameters {
|
||||
let borrowed = borrowed_lifetimes(cont);
|
||||
let generics = build_generics(cont, &borrowed);
|
||||
let has_getter = cont.data.has_getter();
|
||||
let is_packed = cont.attrs.is_packed();
|
||||
|
||||
Parameters {
|
||||
local,
|
||||
@@ -144,6 +148,7 @@ impl Parameters {
|
||||
generics,
|
||||
borrowed,
|
||||
has_getter,
|
||||
is_packed,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -475,7 +480,7 @@ fn deserialize_tuple(
|
||||
};
|
||||
|
||||
let visit_seq = Stmts(deserialize_seq(
|
||||
&type_path, params, fields, false, cattrs, &expecting,
|
||||
&type_path, params, fields, false, cattrs, expecting,
|
||||
));
|
||||
|
||||
let visitor_expr = quote! {
|
||||
@@ -561,7 +566,7 @@ fn deserialize_tuple_in_place(
|
||||
None
|
||||
};
|
||||
|
||||
let visit_seq = Stmts(deserialize_seq_in_place(params, fields, cattrs, &expecting));
|
||||
let visit_seq = Stmts(deserialize_seq_in_place(params, fields, cattrs, expecting));
|
||||
|
||||
let visitor_expr = quote! {
|
||||
__Visitor {
|
||||
@@ -922,7 +927,7 @@ fn deserialize_struct(
|
||||
let expecting = cattrs.expecting().unwrap_or(&expecting);
|
||||
|
||||
let visit_seq = Stmts(deserialize_seq(
|
||||
&type_path, params, fields, true, cattrs, &expecting,
|
||||
&type_path, params, fields, true, cattrs, expecting,
|
||||
));
|
||||
|
||||
let (field_visitor, fields_stmt, visit_map) = if cattrs.has_flatten() {
|
||||
@@ -1063,7 +1068,7 @@ fn deserialize_struct_in_place(
|
||||
};
|
||||
let expecting = cattrs.expecting().unwrap_or(&expecting);
|
||||
|
||||
let visit_seq = Stmts(deserialize_seq_in_place(params, fields, cattrs, &expecting));
|
||||
let visit_seq = Stmts(deserialize_seq_in_place(params, fields, cattrs, expecting));
|
||||
|
||||
let (field_visitor, fields_stmt, visit_map) =
|
||||
deserialize_struct_as_struct_in_place_visitor(params, fields, cattrs);
|
||||
@@ -1453,7 +1458,7 @@ fn deserialize_adjacently_tagged_enum(
|
||||
while let _serde::__private::Some(__k) = #next_key {
|
||||
match __k {
|
||||
_serde::__private::de::TagContentOtherField::Other => {
|
||||
try!(_serde::de::MapAccess::next_value::<_serde::de::IgnoredAny>(&mut __map));
|
||||
let _ = try!(_serde::de::MapAccess::next_value::<_serde::de::IgnoredAny>(&mut __map));
|
||||
continue;
|
||||
},
|
||||
_serde::__private::de::TagContentOtherField::Tag => {
|
||||
@@ -1728,6 +1733,8 @@ fn deserialize_externally_tagged_variant(
|
||||
}
|
||||
}
|
||||
|
||||
// Generates significant part of the visit_seq and visit_map bodies of visitors
|
||||
// for the variants of internally tagged enum.
|
||||
fn deserialize_internally_tagged_variant(
|
||||
params: &Parameters,
|
||||
variant: &Variant,
|
||||
@@ -1779,11 +1786,9 @@ fn deserialize_untagged_variant(
|
||||
deserializer: TokenStream,
|
||||
) -> Fragment {
|
||||
if let Some(path) = variant.attrs.deserialize_with() {
|
||||
let (wrapper, wrapper_ty, unwrap_fn) = wrap_deserialize_variant_with(params, variant, path);
|
||||
let unwrap_fn = unwrap_to_variant_closure(params, variant, false);
|
||||
return quote_block! {
|
||||
#wrapper
|
||||
_serde::__private::Result::map(
|
||||
<#wrapper_ty as _serde::Deserialize>::deserialize(#deserializer), #unwrap_fn)
|
||||
_serde::__private::Result::map(#path(#deserializer), #unwrap_fn)
|
||||
};
|
||||
}
|
||||
|
||||
@@ -2087,7 +2092,7 @@ fn deserialize_identifier(
|
||||
) -> Fragment {
|
||||
let mut flat_fields = Vec::new();
|
||||
for (_, ident, aliases) in fields {
|
||||
flat_fields.extend(aliases.iter().map(|alias| (alias, ident)))
|
||||
flat_fields.extend(aliases.iter().map(|alias| (alias, ident)));
|
||||
}
|
||||
|
||||
let field_strs: &Vec<_> = &flat_fields.iter().map(|(name, _)| name).collect();
|
||||
@@ -2285,7 +2290,7 @@ fn deserialize_identifier(
|
||||
};
|
||||
|
||||
let visit_borrowed = if fallthrough_borrowed.is_some() || collect_other_fields {
|
||||
let fallthrough_borrowed_arm = fallthrough_borrowed.as_ref().unwrap_or(&fallthrough_arm);
|
||||
let fallthrough_borrowed_arm = fallthrough_borrowed.as_ref().unwrap_or(fallthrough_arm);
|
||||
Some(quote! {
|
||||
fn visit_borrowed_str<__E>(self, __value: &'de str) -> _serde::__private::Result<Self::Value, __E>
|
||||
where
|
||||
@@ -2883,44 +2888,61 @@ fn wrap_deserialize_variant_with(
|
||||
variant: &Variant,
|
||||
deserialize_with: &syn::ExprPath,
|
||||
) -> (TokenStream, TokenStream, TokenStream) {
|
||||
let this = ¶ms.this;
|
||||
let variant_ident = &variant.ident;
|
||||
|
||||
let field_tys = variant.fields.iter().map(|field| field.ty);
|
||||
let (wrapper, wrapper_ty) =
|
||||
wrap_deserialize_with(params, "e!((#(#field_tys),*)), deserialize_with);
|
||||
|
||||
let unwrap_fn = unwrap_to_variant_closure(params, variant, true);
|
||||
|
||||
(wrapper, wrapper_ty, unwrap_fn)
|
||||
}
|
||||
|
||||
// Generates closure that converts single input parameter to the final value.
|
||||
fn unwrap_to_variant_closure(
|
||||
params: &Parameters,
|
||||
variant: &Variant,
|
||||
with_wrapper: bool,
|
||||
) -> TokenStream {
|
||||
let this = ¶ms.this;
|
||||
let variant_ident = &variant.ident;
|
||||
|
||||
let (arg, wrapper) = if with_wrapper {
|
||||
(quote! { __wrap }, quote! { __wrap.value })
|
||||
} else {
|
||||
let field_tys = variant.fields.iter().map(|field| field.ty);
|
||||
(quote! { __wrap: (#(#field_tys),*) }, quote! { __wrap })
|
||||
};
|
||||
|
||||
let field_access = (0..variant.fields.len()).map(|n| {
|
||||
Member::Unnamed(Index {
|
||||
index: n as u32,
|
||||
span: Span::call_site(),
|
||||
})
|
||||
});
|
||||
let unwrap_fn = match variant.style {
|
||||
|
||||
match variant.style {
|
||||
Style::Struct if variant.fields.len() == 1 => {
|
||||
let member = &variant.fields[0].member;
|
||||
quote! {
|
||||
|__wrap| #this::#variant_ident { #member: __wrap.value }
|
||||
|#arg| #this::#variant_ident { #member: #wrapper }
|
||||
}
|
||||
}
|
||||
Style::Struct => {
|
||||
let members = variant.fields.iter().map(|field| &field.member);
|
||||
quote! {
|
||||
|__wrap| #this::#variant_ident { #(#members: __wrap.value.#field_access),* }
|
||||
|#arg| #this::#variant_ident { #(#members: #wrapper.#field_access),* }
|
||||
}
|
||||
}
|
||||
Style::Tuple => quote! {
|
||||
|__wrap| #this::#variant_ident(#(__wrap.value.#field_access),*)
|
||||
|#arg| #this::#variant_ident(#(#wrapper.#field_access),*)
|
||||
},
|
||||
Style::Newtype => quote! {
|
||||
|__wrap| #this::#variant_ident(__wrap.value)
|
||||
|#arg| #this::#variant_ident(#wrapper)
|
||||
},
|
||||
Style::Unit => quote! {
|
||||
|__wrap| #this::#variant_ident
|
||||
|#arg| #this::#variant_ident
|
||||
},
|
||||
};
|
||||
|
||||
(wrapper, wrapper_ty, unwrap_fn)
|
||||
}
|
||||
}
|
||||
|
||||
fn expr_is_missing(field: &Field, cattrs: &attr::Container) -> Fragment {
|
||||
|
||||
@@ -23,7 +23,7 @@ pub struct Container<'a> {
|
||||
|
||||
/// The fields of a struct or enum.
|
||||
///
|
||||
/// Analagous to `syn::Data`.
|
||||
/// Analogous to `syn::Data`.
|
||||
pub enum Data<'a> {
|
||||
Enum(Vec<Variant<'a>>),
|
||||
Struct(Style, Vec<Field<'a>>),
|
||||
|
||||
@@ -556,7 +556,7 @@ impl Container {
|
||||
// Parse `#[serde(crate = "foo")]`
|
||||
Meta(NameValue(m)) if m.path == CRATE => {
|
||||
if let Ok(path) = parse_lit_into_path(cx, CRATE, &m.lit) {
|
||||
serde_path.set(&m.path, path)
|
||||
serde_path.set(&m.path, path);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1609,7 +1609,7 @@ fn get_lit_str2<'a>(
|
||||
fn parse_lit_into_path(cx: &Ctxt, attr_name: Symbol, lit: &syn::Lit) -> Result<syn::Path, ()> {
|
||||
let string = get_lit_str(cx, attr_name, lit)?;
|
||||
parse_lit_str(string).map_err(|_| {
|
||||
cx.error_spanned_by(lit, format!("failed to parse path: {:?}", string.value()))
|
||||
cx.error_spanned_by(lit, format!("failed to parse path: {:?}", string.value()));
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1620,7 +1620,7 @@ fn parse_lit_into_expr_path(
|
||||
) -> Result<syn::ExprPath, ()> {
|
||||
let string = get_lit_str(cx, attr_name, lit)?;
|
||||
parse_lit_str(string).map_err(|_| {
|
||||
cx.error_spanned_by(lit, format!("failed to parse path: {:?}", string.value()))
|
||||
cx.error_spanned_by(lit, format!("failed to parse path: {:?}", string.value()));
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1649,7 +1649,7 @@ fn parse_lit_into_ty(cx: &Ctxt, attr_name: Symbol, lit: &syn::Lit) -> Result<syn
|
||||
cx.error_spanned_by(
|
||||
lit,
|
||||
format!("failed to parse type: {} = {:?}", attr_name, string.value()),
|
||||
)
|
||||
);
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -260,7 +260,7 @@ fn check_internal_tag_field_name_conflict(cx: &Ctxt, cont: &Container) {
|
||||
cx.error_spanned_by(
|
||||
cont.original,
|
||||
format!("variant field name `{}` conflicts with internal tag", tag),
|
||||
)
|
||||
);
|
||||
};
|
||||
|
||||
for variant in variants {
|
||||
@@ -396,7 +396,7 @@ fn member_message(member: &Member) -> String {
|
||||
}
|
||||
|
||||
fn allow_transparent(field: &Field, derive: Derive) -> bool {
|
||||
if let Type::Path(ty) = ungroup(&field.ty) {
|
||||
if let Type::Path(ty) = ungroup(field.ty) {
|
||||
if let Some(seg) = ty.path.segments.last() {
|
||||
if seg.ident == "PhantomData" {
|
||||
return false;
|
||||
|
||||
@@ -13,14 +13,15 @@
|
||||
//!
|
||||
//! [https://serde.rs/derive.html]: https://serde.rs/derive.html
|
||||
|
||||
#![doc(html_root_url = "https://docs.rs/serde_derive/1.0.126")]
|
||||
#![doc(html_root_url = "https://docs.rs/serde_derive/1.0.132")]
|
||||
#![allow(unknown_lints, bare_trait_objects)]
|
||||
#![deny(clippy::all, clippy::pedantic)]
|
||||
// Ignored clippy lints
|
||||
#![allow(
|
||||
// clippy false positive: https://github.com/rust-lang/rust-clippy/issues/7054
|
||||
clippy::branches_sharing_code,
|
||||
clippy::cognitive_complexity,
|
||||
// clippy bug: https://github.com/rust-lang/rust-clippy/issues/7575
|
||||
clippy::collapsible_match,
|
||||
clippy::enum_variant_names,
|
||||
// clippy bug: https://github.com/rust-lang/rust-clippy/issues/6797
|
||||
clippy::manual_map,
|
||||
@@ -42,6 +43,7 @@
|
||||
clippy::indexing_slicing,
|
||||
clippy::items_after_statements,
|
||||
clippy::let_underscore_drop,
|
||||
clippy::manual_assert,
|
||||
clippy::map_err_ignore,
|
||||
clippy::match_same_arms,
|
||||
// clippy bug: https://github.com/rust-lang/rust-clippy/issues/6984
|
||||
|
||||
+103
-42
@@ -1,7 +1,7 @@
|
||||
use proc_macro2::{Span, TokenStream};
|
||||
use syn::Ident;
|
||||
use proc_macro2::TokenStream;
|
||||
use quote::format_ident;
|
||||
|
||||
use internals::ast::{Container, Data, Field, Style};
|
||||
use internals::ast::{Container, Data, Field, Style, Variant};
|
||||
|
||||
// Suppress dead_code warnings that would otherwise appear when using a remote
|
||||
// derive. Other than this pretend code, a struct annotated with remote derive
|
||||
@@ -20,8 +20,8 @@ use internals::ast::{Container, Data, Field, Style};
|
||||
// 8 | enum EnumDef { V }
|
||||
// | ^
|
||||
//
|
||||
pub fn pretend_used(cont: &Container) -> TokenStream {
|
||||
let pretend_fields = pretend_fields_used(cont);
|
||||
pub fn pretend_used(cont: &Container, is_packed: bool) -> TokenStream {
|
||||
let pretend_fields = pretend_fields_used(cont, is_packed);
|
||||
let pretend_variants = pretend_variants_used(cont);
|
||||
|
||||
quote! {
|
||||
@@ -32,49 +32,117 @@ pub fn pretend_used(cont: &Container) -> TokenStream {
|
||||
|
||||
// For structs with named fields, expands to:
|
||||
//
|
||||
// match None::<&T> {
|
||||
// Some(T { a: __v0, b: __v1 }) => {}
|
||||
// _ => {}
|
||||
// }
|
||||
//
|
||||
// For packed structs on sufficiently new rustc, expands to:
|
||||
//
|
||||
// match None::<&T> {
|
||||
// Some(__v @ T { a: _, b: _ }) => {
|
||||
// let _ = addr_of!(__v.a);
|
||||
// let _ = addr_of!(__v.b);
|
||||
// }
|
||||
// _ => {}
|
||||
// }
|
||||
//
|
||||
// For packed structs on older rustc, we assume Sized and !Drop, and expand to:
|
||||
//
|
||||
// match None::<T> {
|
||||
// Some(T { a: ref __v0, b: ref __v1 }) => {}
|
||||
// Some(T { a: __v0, b: __v1 }) => {}
|
||||
// _ => {}
|
||||
// }
|
||||
//
|
||||
// For enums, expands to the following but only including struct variants:
|
||||
//
|
||||
// match None::<T> {
|
||||
// Some(T::A { a: ref __v0 }) => {}
|
||||
// Some(T::B { b: ref __v0 }) => {}
|
||||
// match None::<&T> {
|
||||
// Some(T::A { a: __v0 }) => {}
|
||||
// Some(T::B { b: __v0 }) => {}
|
||||
// _ => {}
|
||||
// }
|
||||
//
|
||||
// The `ref` is important in case the user has written a Drop impl on their
|
||||
// type. Rust does not allow destructuring a struct or enum that has a Drop
|
||||
// impl.
|
||||
fn pretend_fields_used(cont: &Container) -> TokenStream {
|
||||
fn pretend_fields_used(cont: &Container, is_packed: bool) -> TokenStream {
|
||||
match &cont.data {
|
||||
Data::Enum(variants) => pretend_fields_used_enum(cont, variants),
|
||||
Data::Struct(Style::Struct, fields) => {
|
||||
if is_packed {
|
||||
pretend_fields_used_struct_packed(cont, fields)
|
||||
} else {
|
||||
pretend_fields_used_struct(cont, fields)
|
||||
}
|
||||
}
|
||||
Data::Struct(_, _) => quote!(),
|
||||
}
|
||||
}
|
||||
|
||||
fn pretend_fields_used_struct(cont: &Container, fields: &[Field]) -> TokenStream {
|
||||
let type_ident = &cont.ident;
|
||||
let (_, ty_generics, _) = cont.generics.split_for_impl();
|
||||
|
||||
let patterns = match &cont.data {
|
||||
Data::Enum(variants) => variants
|
||||
.iter()
|
||||
.filter_map(|variant| match variant.style {
|
||||
Style::Struct => {
|
||||
let variant_ident = &variant.ident;
|
||||
let pat = struct_pattern(&variant.fields);
|
||||
Some(quote!(#type_ident::#variant_ident #pat))
|
||||
}
|
||||
_ => None,
|
||||
})
|
||||
.collect::<Vec<_>>(),
|
||||
Data::Struct(Style::Struct, fields) => {
|
||||
let pat = struct_pattern(fields);
|
||||
vec![quote!(#type_ident #pat)]
|
||||
}
|
||||
Data::Struct(_, _) => {
|
||||
return quote!();
|
||||
}
|
||||
};
|
||||
let members = fields.iter().map(|field| &field.member);
|
||||
let placeholders = (0usize..).map(|i| format_ident!("__v{}", i));
|
||||
|
||||
quote! {
|
||||
match _serde::__private::None::<#type_ident #ty_generics> {
|
||||
match _serde::__private::None::<&#type_ident #ty_generics> {
|
||||
_serde::__private::Some(#type_ident { #(#members: #placeholders),* }) => {}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn pretend_fields_used_struct_packed(cont: &Container, fields: &[Field]) -> TokenStream {
|
||||
let type_ident = &cont.ident;
|
||||
let (_, ty_generics, _) = cont.generics.split_for_impl();
|
||||
|
||||
let members = fields.iter().map(|field| &field.member).collect::<Vec<_>>();
|
||||
|
||||
#[cfg(ptr_addr_of)]
|
||||
{
|
||||
quote! {
|
||||
match _serde::__private::None::<&#type_ident #ty_generics> {
|
||||
_serde::__private::Some(__v @ #type_ident { #(#members: _),* }) => {
|
||||
#(
|
||||
let _ = _serde::__private::ptr::addr_of!(__v.#members);
|
||||
)*
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(ptr_addr_of))]
|
||||
{
|
||||
let placeholders = (0usize..).map(|i| format_ident!("__v{}", i));
|
||||
|
||||
quote! {
|
||||
match _serde::__private::None::<#type_ident #ty_generics> {
|
||||
_serde::__private::Some(#type_ident { #(#members: #placeholders),* }) => {}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn pretend_fields_used_enum(cont: &Container, variants: &[Variant]) -> TokenStream {
|
||||
let type_ident = &cont.ident;
|
||||
let (_, ty_generics, _) = cont.generics.split_for_impl();
|
||||
|
||||
let patterns = variants
|
||||
.iter()
|
||||
.filter_map(|variant| match variant.style {
|
||||
Style::Struct => {
|
||||
let variant_ident = &variant.ident;
|
||||
let members = variant.fields.iter().map(|field| &field.member);
|
||||
let placeholders = (0usize..).map(|i| format_ident!("__v{}", i));
|
||||
Some(quote!(#type_ident::#variant_ident { #(#members: #placeholders),* }))
|
||||
}
|
||||
_ => None,
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
quote! {
|
||||
match _serde::__private::None::<&#type_ident #ty_generics> {
|
||||
#(
|
||||
_serde::__private::Some(#patterns) => {}
|
||||
)*
|
||||
@@ -107,7 +175,7 @@ fn pretend_variants_used(cont: &Container) -> TokenStream {
|
||||
let cases = variants.iter().map(|variant| {
|
||||
let variant_ident = &variant.ident;
|
||||
let placeholders = &(0..variant.fields.len())
|
||||
.map(|i| Ident::new(&format!("__v{}", i), Span::call_site()))
|
||||
.map(|i| format_ident!("__v{}", i))
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
let pat = match variant.style {
|
||||
@@ -131,10 +199,3 @@ fn pretend_variants_used(cont: &Container) -> TokenStream {
|
||||
|
||||
quote!(#(#cases)*)
|
||||
}
|
||||
|
||||
fn struct_pattern(fields: &[Field]) -> TokenStream {
|
||||
let members = fields.iter().map(|field| &field.member);
|
||||
let placeholders =
|
||||
(0..fields.len()).map(|i| Ident::new(&format!("__v{}", i), Span::call_site()));
|
||||
quote!({ #(#members: ref #placeholders),* })
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ pub fn expand_derive_serialize(
|
||||
|
||||
let impl_block = if let Some(remote) = cont.attrs.remote() {
|
||||
let vis = &input.vis;
|
||||
let used = pretend::pretend_used(&cont);
|
||||
let used = pretend::pretend_used(&cont, params.is_packed);
|
||||
quote! {
|
||||
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>
|
||||
@@ -1099,7 +1099,7 @@ fn serialize_struct_visitor(
|
||||
let mut field_expr = if is_enum {
|
||||
quote!(#member)
|
||||
} else {
|
||||
get_member(params, field, &member)
|
||||
get_member(params, field, member)
|
||||
};
|
||||
|
||||
let key_expr = field.attrs.name().serialize_name();
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
name = "serde_derive_internals"
|
||||
version = "0.26.0" # remember to update html_root_url
|
||||
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>", "David Tolnay <dtolnay@gmail.com>"]
|
||||
rust-version = "1.31"
|
||||
license = "MIT OR Apache-2.0"
|
||||
description = "AST representation used by Serde derive macros. Unstable."
|
||||
homepage = "https://serde.rs"
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
#![doc(html_root_url = "https://docs.rs/serde_derive_internals/0.26.0")]
|
||||
#![allow(unknown_lints, bare_trait_objects)]
|
||||
#![deny(clippy::all, clippy::pedantic)]
|
||||
// Ignored clippy lints
|
||||
#![allow(
|
||||
clippy::cognitive_complexity,
|
||||
// clippy bug: https://github.com/rust-lang/rust-clippy/issues/7575
|
||||
clippy::collapsible_match,
|
||||
// clippy bug: https://github.com/rust-lang/rust-clippy/issues/6797
|
||||
clippy::manual_map,
|
||||
clippy::missing_panics_doc,
|
||||
@@ -21,6 +22,7 @@
|
||||
clippy::enum_glob_use,
|
||||
clippy::items_after_statements,
|
||||
clippy::let_underscore_drop,
|
||||
clippy::manual_assert,
|
||||
clippy::match_same_arms,
|
||||
// clippy bug: https://github.com/rust-lang/rust-clippy/issues/6984
|
||||
clippy::match_wildcard_for_single_variants,
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
[package]
|
||||
name = "serde_test"
|
||||
version = "1.0.126" # remember to update html_root_url
|
||||
version = "1.0.132" # remember to update html_root_url
|
||||
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>", "David Tolnay <dtolnay@gmail.com>"]
|
||||
rust-version = "1.15"
|
||||
license = "MIT OR Apache-2.0"
|
||||
description = "Token De/Serializer for testing De/Serialize implementations"
|
||||
homepage = "https://serde.rs"
|
||||
|
||||
@@ -144,9 +144,8 @@
|
||||
//! # }
|
||||
//! ```
|
||||
|
||||
#![doc(html_root_url = "https://docs.rs/serde_test/1.0.126")]
|
||||
#![doc(html_root_url = "https://docs.rs/serde_test/1.0.132")]
|
||||
#![cfg_attr(feature = "cargo-clippy", allow(renamed_and_removed_lints))]
|
||||
#![cfg_attr(feature = "cargo-clippy", deny(clippy, clippy_pedantic))]
|
||||
// Ignored clippy lints
|
||||
#![cfg_attr(feature = "cargo-clippy", allow(float_cmp, needless_doctest_main))]
|
||||
// Ignored clippy_pedantic lints
|
||||
@@ -155,6 +154,7 @@
|
||||
allow(
|
||||
cloned_instead_of_copied,
|
||||
empty_line_after_outer_attr,
|
||||
manual_assert,
|
||||
missing_docs_in_private_items,
|
||||
missing_panics_doc,
|
||||
module_name_repetitions,
|
||||
|
||||
@@ -32,18 +32,18 @@ impl<'a> Serializer<'a> {
|
||||
}
|
||||
|
||||
macro_rules! assert_next_token {
|
||||
($ser:expr, $actual:ident) => {
|
||||
($ser:expr, $actual:ident) => {{
|
||||
assert_next_token!($ser, stringify!($actual), Token::$actual, true);
|
||||
};
|
||||
($ser:expr, $actual:ident($v:expr)) => {
|
||||
}};
|
||||
($ser:expr, $actual:ident($v:expr)) => {{
|
||||
assert_next_token!(
|
||||
$ser,
|
||||
format_args!(concat!(stringify!($actual), "({:?})"), $v),
|
||||
Token::$actual(v),
|
||||
v == $v
|
||||
);
|
||||
};
|
||||
($ser:expr, $actual:ident { $($k:ident),* }) => {
|
||||
}};
|
||||
($ser:expr, $actual:ident { $($k:ident),* }) => {{
|
||||
let compare = ($($k,)*);
|
||||
let field_format = || {
|
||||
use std::fmt::Write;
|
||||
@@ -59,7 +59,7 @@ macro_rules! assert_next_token {
|
||||
Token::$actual { $($k),* },
|
||||
($($k,)*) == compare
|
||||
);
|
||||
};
|
||||
}};
|
||||
($ser:expr, $actual:expr, $pat:pat, $guard:expr) => {
|
||||
match $ser.next_token() {
|
||||
Some($pat) if $guard => {}
|
||||
|
||||
@@ -23,4 +23,4 @@ rustversion = "1.0"
|
||||
serde = { path = "../serde", features = ["rc", "derive"] }
|
||||
serde_derive = { path = "../serde_derive", features = ["deserialize_in_place"] }
|
||||
serde_test = { path = "../serde_test" }
|
||||
trybuild = { version = "1.0.19", features = ["diff"] }
|
||||
trybuild = { version = "1.0.49", features = ["diff"] }
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
#![allow(
|
||||
clippy::cast_lossless,
|
||||
clippy::from_over_into,
|
||||
// Clippy bug: https://github.com/rust-lang/rust-clippy/issues/7422
|
||||
clippy::nonstandard_macro_braces,
|
||||
clippy::too_many_lines,
|
||||
clippy::trivially_copy_pass_by_ref
|
||||
)]
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
#![allow(clippy::items_after_statements, clippy::used_underscore_binding)]
|
||||
|
||||
use serde::{Deserialize, Deserializer};
|
||||
use serde_test::{assert_de_tokens, assert_de_tokens_error, Token};
|
||||
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
#![allow(clippy::decimal_literal_representation, clippy::unreadable_literal)]
|
||||
#![allow(
|
||||
clippy::decimal_literal_representation,
|
||||
clippy::empty_enum,
|
||||
clippy::manual_assert,
|
||||
clippy::needless_pass_by_value,
|
||||
clippy::unreadable_literal
|
||||
)]
|
||||
#![cfg_attr(feature = "unstable", feature(never_type))]
|
||||
|
||||
use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet};
|
||||
|
||||
@@ -6,7 +6,14 @@
|
||||
#![allow(
|
||||
unknown_lints,
|
||||
mixed_script_confusables,
|
||||
clippy::items_after_statements,
|
||||
clippy::missing_errors_doc,
|
||||
clippy::missing_panics_doc,
|
||||
clippy::must_use_candidate,
|
||||
// Clippy bug: https://github.com/rust-lang/rust-clippy/issues/7422
|
||||
clippy::nonstandard_macro_braces,
|
||||
clippy::ptr_arg,
|
||||
clippy::too_many_lines,
|
||||
clippy::trivially_copy_pass_by_ref
|
||||
)]
|
||||
|
||||
@@ -641,7 +648,7 @@ fn test_gen() {
|
||||
assert::<SkippedVariant<X>>();
|
||||
|
||||
#[derive(Deserialize)]
|
||||
struct ImpliciltyBorrowedOption<'a> {
|
||||
struct ImplicitlyBorrowedOption<'a> {
|
||||
option: std::option::Option<&'a str>,
|
||||
}
|
||||
|
||||
@@ -821,3 +828,64 @@ where
|
||||
{
|
||||
vec.first().serialize(serializer)
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#[derive(Debug, PartialEq, Deserialize)]
|
||||
#[serde(tag = "tag")]
|
||||
enum InternallyTagged {
|
||||
#[serde(deserialize_with = "deserialize_generic")]
|
||||
Unit,
|
||||
|
||||
#[serde(deserialize_with = "deserialize_generic")]
|
||||
Newtype(i32),
|
||||
|
||||
#[serde(deserialize_with = "deserialize_generic")]
|
||||
Struct { f1: String, f2: u8 },
|
||||
}
|
||||
|
||||
fn deserialize_generic<'de, T, D>(deserializer: D) -> StdResult<T, D::Error>
|
||||
where
|
||||
T: Deserialize<'de>,
|
||||
D: Deserializer<'de>,
|
||||
{
|
||||
T::deserialize(deserializer)
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#[repr(packed)]
|
||||
pub struct RemotePacked {
|
||||
pub a: u16,
|
||||
pub b: u32,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[repr(packed)]
|
||||
#[serde(remote = "RemotePacked")]
|
||||
pub struct RemotePackedDef {
|
||||
a: u16,
|
||||
b: u32,
|
||||
}
|
||||
|
||||
impl Drop for RemotePackedDef {
|
||||
fn drop(&mut self) {}
|
||||
}
|
||||
|
||||
#[repr(packed)]
|
||||
pub struct RemotePackedNonCopy {
|
||||
pub a: u16,
|
||||
pub b: String,
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
#[repr(packed)]
|
||||
#[serde(remote = "RemotePackedNonCopy")]
|
||||
pub struct RemotePackedNonCopyDef {
|
||||
a: u16,
|
||||
b: String,
|
||||
}
|
||||
|
||||
impl Drop for RemotePackedNonCopyDef {
|
||||
fn drop(&mut self) {}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
#![deny(trivial_numeric_casts)]
|
||||
#![allow(clippy::redundant_field_names)]
|
||||
#![allow(
|
||||
clippy::enum_variant_names,
|
||||
clippy::redundant_field_names,
|
||||
clippy::too_many_lines
|
||||
)]
|
||||
|
||||
mod bytes;
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
#![allow(clippy::used_underscore_binding)]
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
#![allow(clippy::type_repetition_in_bounds)]
|
||||
|
||||
#[test]
|
||||
fn test_gen_custom_serde() {
|
||||
#[derive(serde::Serialize, serde::Deserialize)]
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
#![allow(clippy::similar_names)]
|
||||
|
||||
use serde::de::value::{self, MapAccessDeserializer};
|
||||
use serde::de::{IntoDeserializer, MapAccess, Visitor};
|
||||
use serde::{Deserialize, Deserializer};
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
error: failed to parse borrowed lifetimes: "zzz"
|
||||
--> $DIR/bad_lifetimes.rs:5:22
|
||||
--> tests/ui/borrow/bad_lifetimes.rs:5:22
|
||||
|
|
||||
5 | #[serde(borrow = "zzz")]
|
||||
| ^^^^^
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
error: duplicate borrowed lifetime `'a`
|
||||
--> $DIR/duplicate_lifetime.rs:5:22
|
||||
--> tests/ui/borrow/duplicate_lifetime.rs:5:22
|
||||
|
|
||||
5 | #[serde(borrow = "'a + 'a")]
|
||||
| ^^^^^^^^^
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
error: duplicate serde attribute `borrow`
|
||||
--> $DIR/duplicate_variant.rs:8:13
|
||||
--> tests/ui/borrow/duplicate_variant.rs:8:13
|
||||
|
|
||||
8 | #[serde(borrow)]
|
||||
| ^^^^^^
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
error: at least one lifetime must be borrowed
|
||||
--> $DIR/empty_lifetimes.rs:5:22
|
||||
--> tests/ui/borrow/empty_lifetimes.rs:5:22
|
||||
|
|
||||
5 | #[serde(borrow = "")]
|
||||
| ^^
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
error: field `s` has no lifetimes to borrow
|
||||
--> $DIR/no_lifetimes.rs:5:5
|
||||
--> tests/ui/borrow/no_lifetimes.rs:5:5
|
||||
|
|
||||
5 | / #[serde(borrow)]
|
||||
6 | | s: String,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
error: #[serde(borrow)] may only be used on newtype variants
|
||||
--> $DIR/struct_variant.rs:8:5
|
||||
--> tests/ui/borrow/struct_variant.rs:8:5
|
||||
|
|
||||
8 | / #[serde(borrow)]
|
||||
9 | | S { s: Str<'a> },
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
error: field `s` does not have lifetime 'b
|
||||
--> $DIR/wrong_lifetime.rs:5:5
|
||||
--> tests/ui/borrow/wrong_lifetime.rs:5:5
|
||||
|
|
||||
5 | / #[serde(borrow = "'b")]
|
||||
6 | | s: &'a str,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
error: enum tags `conflict` for type and content conflict with each other
|
||||
--> $DIR/adjacent-tag.rs:4:1
|
||||
--> tests/ui/conflict/adjacent-tag.rs:4:1
|
||||
|
|
||||
4 | / #[serde(tag = "conflict", content = "conflict")]
|
||||
5 | | enum E {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
error: #[serde(flatten)] cannot be used on newtype structs
|
||||
--> $DIR/flatten-newtype-struct.rs:6:12
|
||||
--> tests/ui/conflict/flatten-newtype-struct.rs:6:12
|
||||
|
|
||||
6 | struct Foo(#[serde(flatten)] HashMap<String, String>);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
error: #[serde(flatten)] cannot be used on tuple structs
|
||||
--> $DIR/flatten-tuple-struct.rs:6:17
|
||||
--> tests/ui/conflict/flatten-tuple-struct.rs:6:17
|
||||
|
|
||||
6 | struct Foo(u32, #[serde(flatten)] HashMap<String, String>);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
error: #[serde(from = "...")] and #[serde(try_from = "...")] conflict with each other
|
||||
--> $DIR/from-try-from.rs:4:1
|
||||
--> tests/ui/conflict/from-try-from.rs:4:1
|
||||
|
|
||||
4 | / #[serde(from = "u64", try_from = "u64")]
|
||||
5 | | struct S {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
error: variant field name `conflict` conflicts with internal tag
|
||||
--> $DIR/internal-tag-alias.rs:4:1
|
||||
--> tests/ui/conflict/internal-tag-alias.rs:4:1
|
||||
|
|
||||
4 | / #[serde(tag = "conflict")]
|
||||
5 | | enum E {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
error: variant field name `conflict` conflicts with internal tag
|
||||
--> $DIR/internal-tag.rs:4:1
|
||||
--> tests/ui/conflict/internal-tag.rs:4:1
|
||||
|
|
||||
4 | / #[serde(tag = "conflict")]
|
||||
5 | | enum E {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
error: #[serde(default)] can only be used on structs with named fields
|
||||
--> $DIR/enum.rs:5:1
|
||||
--> tests/ui/default-attribute/enum.rs:5:1
|
||||
|
|
||||
5 | enum E {
|
||||
| ^^^^
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
error: #[serde(default = "...")] can only be used on structs with named fields
|
||||
--> $DIR/enum_path.rs:5:1
|
||||
--> tests/ui/default-attribute/enum_path.rs:5:1
|
||||
|
|
||||
5 | enum E {
|
||||
| ^^^^
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
error: #[serde(default)] can only be used on structs with named fields
|
||||
--> $DIR/nameless_struct_fields.rs:5:9
|
||||
--> tests/ui/default-attribute/nameless_struct_fields.rs:5:9
|
||||
|
|
||||
5 | struct T(u8, u8);
|
||||
| ^^^^^^^^
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
error: #[serde(default = "...")] can only be used on structs with named fields
|
||||
--> $DIR/nameless_struct_fields_path.rs:5:9
|
||||
--> tests/ui/default-attribute/nameless_struct_fields_path.rs:5:9
|
||||
|
|
||||
5 | struct T(u8, u8);
|
||||
| ^^^^^^^^
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
error: unknown serde field attribute `serialize`
|
||||
--> $DIR/rename-and-ser.rs:5:27
|
||||
--> tests/ui/duplicate-attribute/rename-and-ser.rs:5:27
|
||||
|
|
||||
5 | #[serde(rename = "x", serialize = "y")]
|
||||
| ^^^^^^^^^
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
error: duplicate serde attribute `rename`
|
||||
--> $DIR/rename-ser-rename-ser.rs:5:38
|
||||
--> tests/ui/duplicate-attribute/rename-ser-rename-ser.rs:5:38
|
||||
|
|
||||
5 | #[serde(rename(serialize = "x"), rename(serialize = "y"))]
|
||||
| ^^^^^^
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
error: duplicate serde attribute `rename`
|
||||
--> $DIR/rename-ser-rename.rs:6:13
|
||||
--> tests/ui/duplicate-attribute/rename-ser-rename.rs:6:13
|
||||
|
|
||||
6 | #[serde(rename = "y")]
|
||||
| ^^^^^^
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
error: duplicate serde attribute `rename`
|
||||
--> $DIR/rename-ser-ser.rs:5:37
|
||||
--> tests/ui/duplicate-attribute/rename-ser-ser.rs:5:37
|
||||
|
|
||||
5 | #[serde(rename(serialize = "x", serialize = "y"))]
|
||||
| ^^^^^^^^^
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
error: duplicate serde attribute `rename`
|
||||
--> $DIR/two-rename-ser.rs:6:13
|
||||
--> tests/ui/duplicate-attribute/two-rename-ser.rs:6:13
|
||||
|
|
||||
6 | #[serde(rename(serialize = "y"))]
|
||||
| ^^^^^^
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
error: duplicate serde attribute `serialize_with`
|
||||
--> $DIR/with-and-serialize-with.rs:5:25
|
||||
--> tests/ui/duplicate-attribute/with-and-serialize-with.rs:5:25
|
||||
|
|
||||
5 | #[serde(with = "w", serialize_with = "s")]
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
error: #[serde(tag = "...", content = "...")] must be used together
|
||||
--> $DIR/content-no-tag.rs:4:9
|
||||
--> tests/ui/enum-representation/content-no-tag.rs:4:9
|
||||
|
|
||||
4 | #[serde(content = "c")]
|
||||
| ^^^^^^^
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
error: #[serde(tag = "...")] cannot be used with tuple variants
|
||||
--> $DIR/internal-tuple-variant.rs:6:5
|
||||
--> tests/ui/enum-representation/internal-tuple-variant.rs:6:5
|
||||
|
|
||||
6 | Tuple(u8, u8),
|
||||
| ^^^^^^^^^^^^^
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
error: untagged enum cannot have #[serde(tag = "...", content = "...")]
|
||||
--> $DIR/untagged-and-adjacent.rs:4:9
|
||||
--> tests/ui/enum-representation/untagged-and-adjacent.rs:4:9
|
||||
|
|
||||
4 | #[serde(untagged)]
|
||||
| ^^^^^^^^
|
||||
|
||||
error: untagged enum cannot have #[serde(tag = "...", content = "...")]
|
||||
--> $DIR/untagged-and-adjacent.rs:5:9
|
||||
--> tests/ui/enum-representation/untagged-and-adjacent.rs:5:9
|
||||
|
|
||||
5 | #[serde(tag = "t", content = "c")]
|
||||
| ^^^
|
||||
|
||||
error: untagged enum cannot have #[serde(tag = "...", content = "...")]
|
||||
--> $DIR/untagged-and-adjacent.rs:5:20
|
||||
--> tests/ui/enum-representation/untagged-and-adjacent.rs:5:20
|
||||
|
|
||||
5 | #[serde(tag = "t", content = "c")]
|
||||
| ^^^^^^^
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
error: untagged enum cannot have #[serde(content = "...")]
|
||||
--> $DIR/untagged-and-content.rs:4:9
|
||||
--> tests/ui/enum-representation/untagged-and-content.rs:4:9
|
||||
|
|
||||
4 | #[serde(untagged)]
|
||||
| ^^^^^^^^
|
||||
|
||||
error: untagged enum cannot have #[serde(content = "...")]
|
||||
--> $DIR/untagged-and-content.rs:5:9
|
||||
--> tests/ui/enum-representation/untagged-and-content.rs:5:9
|
||||
|
|
||||
5 | #[serde(content = "c")]
|
||||
| ^^^^^^^
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
error: enum cannot be both untagged and internally tagged
|
||||
--> $DIR/untagged-and-internal.rs:4:9
|
||||
--> tests/ui/enum-representation/untagged-and-internal.rs:4:9
|
||||
|
|
||||
4 | #[serde(untagged)]
|
||||
| ^^^^^^^^
|
||||
|
||||
error: enum cannot be both untagged and internally tagged
|
||||
--> $DIR/untagged-and-internal.rs:5:9
|
||||
--> tests/ui/enum-representation/untagged-and-internal.rs:5:9
|
||||
|
|
||||
5 | #[serde(tag = "type")]
|
||||
| ^^^
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
error: #[serde(untagged)] can only be used on enums
|
||||
--> $DIR/untagged-struct.rs:5:1
|
||||
--> tests/ui/enum-representation/untagged-struct.rs:5:1
|
||||
|
|
||||
5 | struct S;
|
||||
| ^^^^^^
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
error: expected serde rename attribute to be a string: `rename = "..."`
|
||||
--> $DIR/boolean.rs:5:22
|
||||
--> tests/ui/expected-string/boolean.rs:5:22
|
||||
|
|
||||
5 | #[serde(rename = true)]
|
||||
| ^^^^
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
error: expected serde rename attribute to be a string: `rename = "..."`
|
||||
--> $DIR/byte_character.rs:5:22
|
||||
--> tests/ui/expected-string/byte_character.rs:5:22
|
||||
|
|
||||
5 | #[serde(rename = b'a')]
|
||||
| ^^^^
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
error: expected serde rename attribute to be a string: `rename = "..."`
|
||||
--> $DIR/byte_string.rs:5:22
|
||||
--> tests/ui/expected-string/byte_string.rs:5:22
|
||||
|
|
||||
5 | #[serde(rename = b"byte string")]
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
error: expected serde rename attribute to be a string: `rename = "..."`
|
||||
--> $DIR/character.rs:5:22
|
||||
--> tests/ui/expected-string/character.rs:5:22
|
||||
|
|
||||
5 | #[serde(rename = 'a')]
|
||||
| ^^^
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
error: expected serde rename attribute to be a string: `rename = "..."`
|
||||
--> $DIR/float.rs:5:22
|
||||
--> tests/ui/expected-string/float.rs:5:22
|
||||
|
|
||||
5 | #[serde(rename = 3.14)]
|
||||
| ^^^^
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
error: expected serde rename attribute to be a string: `rename = "..."`
|
||||
--> $DIR/integer.rs:5:22
|
||||
--> tests/ui/expected-string/integer.rs:5:22
|
||||
|
|
||||
5 | #[serde(rename = 100)]
|
||||
| ^^^
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
error: #[serde(field_identifier)] and #[serde(variant_identifier)] cannot both be set
|
||||
--> $DIR/both.rs:4:9
|
||||
--> tests/ui/identifier/both.rs:4:9
|
||||
|
|
||||
4 | #[serde(field_identifier, variant_identifier)]
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
||||
error: #[serde(field_identifier)] and #[serde(variant_identifier)] cannot both be set
|
||||
--> $DIR/both.rs:4:27
|
||||
--> tests/ui/identifier/both.rs:4:27
|
||||
|
|
||||
4 | #[serde(field_identifier, variant_identifier)]
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
error: #[serde(field_identifier)] can only be used on an enum
|
||||
--> $DIR/field_struct.rs:5:1
|
||||
--> tests/ui/identifier/field_struct.rs:5:1
|
||||
|
|
||||
5 | struct S;
|
||||
| ^^^^^^
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
error: #[serde(field_identifier)] may only contain unit variants
|
||||
--> $DIR/field_tuple.rs:7:5
|
||||
--> tests/ui/identifier/field_tuple.rs:7:5
|
||||
|
|
||||
7 | B(u8, u8),
|
||||
| ^^^^^^^^^
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
error: `Other` must be the last variant
|
||||
--> $DIR/newtype_not_last.rs:7:5
|
||||
--> tests/ui/identifier/newtype_not_last.rs:7:5
|
||||
|
|
||||
7 | Other(String),
|
||||
| ^^^^^^^^^^^^^
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
error: #[serde(other)] must be on a unit variant
|
||||
--> $DIR/not_unit.rs:7:5
|
||||
--> tests/ui/identifier/not_unit.rs:7:5
|
||||
|
|
||||
7 | / #[serde(other)]
|
||||
8 | | Other(u8, u8),
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
error: #[serde(other)] must be on the last variant
|
||||
--> $DIR/other_not_last.rs:7:5
|
||||
--> tests/ui/identifier/other_not_last.rs:7:5
|
||||
|
|
||||
7 | / #[serde(other)]
|
||||
8 | | Other,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
error: #[serde(other)] cannot appear on untagged enum
|
||||
--> $DIR/other_untagged.rs:6:5
|
||||
--> tests/ui/identifier/other_untagged.rs:6:5
|
||||
|
|
||||
6 | / #[serde(other)]
|
||||
7 | | Other,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
error: #[serde(other)] may not be used on a variant identifier
|
||||
--> $DIR/other_variant.rs:6:5
|
||||
--> tests/ui/identifier/other_variant.rs:6:5
|
||||
|
|
||||
6 | / #[serde(other)]
|
||||
7 | | Other,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
error: #[serde(variant_identifier)] can only be used on an enum
|
||||
--> $DIR/variant_struct.rs:5:1
|
||||
--> tests/ui/identifier/variant_struct.rs:5:1
|
||||
|
|
||||
5 | struct S;
|
||||
| ^^^^^^
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
error: #[serde(variant_identifier)] may only contain unit variants
|
||||
--> $DIR/variant_tuple.rs:7:5
|
||||
--> tests/ui/identifier/variant_tuple.rs:7:5
|
||||
|
|
||||
7 | B(u8, u8),
|
||||
| ^^^^^^^^^
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
error: malformed bound attribute, expected `bound(serialize = ..., deserialize = ...)`
|
||||
--> $DIR/bound.rs:5:19
|
||||
--> tests/ui/malformed/bound.rs:5:19
|
||||
|
|
||||
5 | #[serde(bound(unknown))]
|
||||
| ^^^^^^^
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
error: unexpected end of input, expected literal
|
||||
--> $DIR/cut_off.rs:4:17
|
||||
--> tests/ui/malformed/cut_off.rs:4:17
|
||||
|
|
||||
4 | #[serde(rename =)]
|
||||
| ^
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
error: expected #[serde(...)]
|
||||
--> $DIR/not_list.rs:4:3
|
||||
--> tests/ui/malformed/not_list.rs:4:3
|
||||
|
|
||||
4 | #[serde]
|
||||
| ^^^^^
|
||||
|
||||
error: expected #[serde(...)]
|
||||
--> $DIR/not_list.rs:5:3
|
||||
--> tests/ui/malformed/not_list.rs:5:3
|
||||
|
|
||||
5 | #[serde = "?"]
|
||||
| ^^^^^^^^^^^
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
error: malformed rename attribute, expected `rename(serialize = ..., deserialize = ...)`
|
||||
--> $DIR/rename.rs:5:20
|
||||
--> tests/ui/malformed/rename.rs:5:20
|
||||
|
|
||||
5 | #[serde(rename(unknown))]
|
||||
| ^^^^^^^
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
error: cannot deserialize when there is a lifetime parameter called 'de
|
||||
--> $DIR/deserialize_de_lifetime.rs:4:10
|
||||
--> tests/ui/precondition/deserialize_de_lifetime.rs:4:10
|
||||
|
|
||||
4 | struct S<'de> {
|
||||
| ^^^
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
error: cannot deserialize a dynamically sized struct
|
||||
--> $DIR/deserialize_dst.rs:4:1
|
||||
--> tests/ui/precondition/deserialize_dst.rs:4:1
|
||||
|
|
||||
4 | / struct S {
|
||||
5 | | string: String,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
error: field identifiers cannot be serialized
|
||||
--> $DIR/serialize_field_identifier.rs:4:1
|
||||
--> tests/ui/precondition/serialize_field_identifier.rs:4:1
|
||||
|
|
||||
4 | / #[serde(field_identifier)]
|
||||
5 | | enum F {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
error: variant identifiers cannot be serialized
|
||||
--> $DIR/serialize_variant_identifier.rs:4:1
|
||||
--> tests/ui/precondition/serialize_variant_identifier.rs:4:1
|
||||
|
|
||||
4 | / #[serde(variant_identifier)]
|
||||
5 | | enum F {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
error: failed to parse path: "~~~"
|
||||
--> $DIR/bad_getter.rs:12:22
|
||||
--> tests/ui/remote/bad_getter.rs:12:22
|
||||
|
|
||||
12 | #[serde(getter = "~~~")]
|
||||
| ^^^^^
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
error: failed to parse path: "~~~"
|
||||
--> $DIR/bad_remote.rs:10:18
|
||||
--> tests/ui/remote/bad_remote.rs:10:18
|
||||
|
|
||||
10 | #[serde(remote = "~~~")]
|
||||
| ^^^^^
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
error: #[serde(getter = "...")] is not allowed in an enum
|
||||
--> $DIR/enum_getter.rs:10:1
|
||||
--> tests/ui/remote/enum_getter.rs:10:1
|
||||
|
|
||||
10 | / #[serde(remote = "remote::E")]
|
||||
11 | | pub enum E {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
error[E0063]: missing field `b` in initializer of `remote::S`
|
||||
--> $DIR/missing_field.rs:11:18
|
||||
--> tests/ui/remote/missing_field.rs:11:18
|
||||
|
|
||||
11 | #[serde(remote = "remote::S")]
|
||||
| ^^^^^^^^^^^ missing `b`
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
error: #[serde(getter = "...")] can only be used in structs that have #[serde(remote = "...")]
|
||||
--> $DIR/nonremote_getter.rs:4:1
|
||||
--> tests/ui/remote/nonremote_getter.rs:4:1
|
||||
|
|
||||
4 | / struct S {
|
||||
5 | | #[serde(getter = "S::get")]
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
error[E0609]: no field `b` on type `&remote::S`
|
||||
--> $DIR/unknown_field.rs:12:5
|
||||
--> tests/ui/remote/unknown_field.rs:12:5
|
||||
|
|
||||
12 | b: u8,
|
||||
| ^ help: a field with a similar name exists: `a`
|
||||
|
||||
error[E0560]: struct `remote::S` has no field named `b`
|
||||
--> $DIR/unknown_field.rs:12:5
|
||||
--> tests/ui/remote/unknown_field.rs:12:5
|
||||
|
|
||||
12 | b: u8,
|
||||
| ^ help: a field with a similar name exists: `a`
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/wrong_de.rs:7:10
|
||||
--> tests/ui/remote/wrong_de.rs:7:10
|
||||
|
|
||||
7 | #[derive(Deserialize)]
|
||||
| ^^^^^^^^^^^
|
||||
| |
|
||||
| expected `u16`, found `u8`
|
||||
| help: you can convert a `u8` to a `u16`: `Deserialize.into()`
|
||||
| ^^^^^^^^^^^ expected `u16`, found `u8`
|
||||
|
|
||||
= note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
= note: this error originates in the derive macro `Deserialize` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
help: you can convert a `u8` to a `u16`
|
||||
|
|
||||
7 | #[derive(Deserialize.into())]
|
||||
| +++++++
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/wrong_getter.rs:15:10
|
||||
--> tests/ui/remote/wrong_getter.rs:15:10
|
||||
|
|
||||
15 | #[derive(Serialize)]
|
||||
| ^^^^^^^^^ expected `u8`, found `u16`
|
||||
|
|
||||
= note: expected reference `&u8`
|
||||
found reference `&u16`
|
||||
= note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
= note: this error originates in the derive macro `Serialize` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/wrong_ser.rs:9:10
|
||||
--> tests/ui/remote/wrong_ser.rs:9:10
|
||||
|
|
||||
9 | #[derive(Serialize)]
|
||||
| ^^^^^^^^^ expected `u8`, found `u16`
|
||||
|
|
||||
= note: expected reference `&u8`
|
||||
found reference `&u16`
|
||||
= note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
= note: this error originates in the derive macro `Serialize` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
error: unknown rename rule `rename_all = "abc"`, expected one of "lowercase", "UPPERCASE", "PascalCase", "camelCase", "snake_case", "SCREAMING_SNAKE_CASE", "kebab-case", "SCREAMING-KEBAB-CASE"
|
||||
--> $DIR/container_unknown_rename_rule.rs:4:22
|
||||
--> tests/ui/rename/container_unknown_rename_rule.rs:4:22
|
||||
|
|
||||
4 | #[serde(rename_all = "abc")]
|
||||
| ^^^^^
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
error: unknown rename rule `rename_all = "abc"`, expected one of "lowercase", "UPPERCASE", "PascalCase", "camelCase", "snake_case", "SCREAMING_SNAKE_CASE", "kebab-case", "SCREAMING-KEBAB-CASE"
|
||||
--> $DIR/variant_unknown_rename_rule.rs:5:26
|
||||
--> tests/ui/rename/variant_unknown_rename_rule.rs:5:26
|
||||
|
|
||||
5 | #[serde(rename_all = "abc")]
|
||||
| ^^^^^
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
error: #[serde(tag = "...")] can only be used on enums and structs with named fields
|
||||
--> $DIR/internally-tagged-tuple.rs:5:9
|
||||
--> tests/ui/struct-representation/internally-tagged-tuple.rs:5:9
|
||||
|
|
||||
5 | struct S(u8, u8);
|
||||
| ^^^^^^^^
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
error: #[serde(tag = "...")] can only be used on enums and structs with named fields
|
||||
--> $DIR/internally-tagged-unit.rs:3:10
|
||||
--> tests/ui/struct-representation/internally-tagged-unit.rs:3:10
|
||||
|
|
||||
3 | #[derive(Serialize)]
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
= note: this error originates in the derive macro `Serialize` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
error: #[serde(transparent)] requires struct to have at most one transparent field
|
||||
--> $DIR/at_most_one.rs:4:1
|
||||
--> tests/ui/transparent/at_most_one.rs:4:1
|
||||
|
|
||||
4 | / #[serde(transparent)]
|
||||
5 | | struct S {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user