mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-04-23 03:38:00 +00:00
Compare commits
40 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| fc3f104c4a | |||
| 4bec9ffd0f | |||
| e6d2322e68 | |||
| 2b504099e4 | |||
| be7d0e7eb2 | |||
| b539cb45d7 | |||
| a5490e20e1 | |||
| 45c45e87bf | |||
| 2e76f7013f | |||
| d35de19120 | |||
| e5b3507145 | |||
| 7ea7c2ceb9 | |||
| 2b5b15967e | |||
| 2ef60b62ac | |||
| e6f086d85e | |||
| bf76f50294 | |||
| ba07075590 | |||
| 26186bddd1 | |||
| 53b9871b17 | |||
| f8787c3ca8 | |||
| 3022064f84 | |||
| 9e140a2071 | |||
| 24e6acbfae | |||
| 29c5a50935 | |||
| c619b2a7c4 | |||
| 764ebd9b17 | |||
| 9c6f0c3a0e | |||
| a9f8ea0a1e | |||
| 04faac962a | |||
| 7e5701ad2b | |||
| 1cd10a7d09 | |||
| d5e6436b28 | |||
| 8ff11dc234 | |||
| 6b3777b617 | |||
| 7350b58f5c | |||
| 7351e0e55a | |||
| b3ff7e43ef | |||
| a50e1c20e9 | |||
| 6980727d74 | |||
| bb1dedf04d |
@@ -1,7 +0,0 @@
|
||||
---
|
||||
name: Help or discussion
|
||||
about: This is the right place
|
||||
|
||||
---
|
||||
|
||||
|
||||
+1
-1
@@ -58,4 +58,4 @@ In all Serde-related forums, we follow the [Rust Code of Conduct]. For
|
||||
escalation or moderation issues please contact Erick (erick.tryzelaar@gmail.com)
|
||||
instead of the Rust moderation team.
|
||||
|
||||
[Rust Code of Conduct]: https://www.rust-lang.org/conduct.html
|
||||
[Rust Code of Conduct]: https://www.rust-lang.org/policies/code-of-conduct
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
error_on_line_overflow = false
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "serde"
|
||||
version = "1.0.112" # remember to update html_root_url and serde_derive dependency
|
||||
version = "1.0.117" # remember to update html_root_url and serde_derive dependency
|
||||
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>", "David Tolnay <dtolnay@gmail.com>"]
|
||||
license = "MIT OR Apache-2.0"
|
||||
description = "A generic serialization/deserialization framework"
|
||||
@@ -14,7 +14,7 @@ include = ["build.rs", "src/**/*.rs", "crates-io.md", "README.md", "LICENSE-APAC
|
||||
build = "build.rs"
|
||||
|
||||
[dependencies]
|
||||
serde_derive = { version = "=1.0.112", optional = true, path = "../serde_derive" }
|
||||
serde_derive = { version = "=1.0.117", optional = true, path = "../serde_derive" }
|
||||
|
||||
[dev-dependencies]
|
||||
serde_derive = { version = "1.0", path = "../serde_derive" }
|
||||
|
||||
+1
-1
@@ -66,7 +66,7 @@ fn main() {
|
||||
}
|
||||
|
||||
// Non-zero integers stabilized in Rust 1.28:
|
||||
// https://github.com/rust-lang/rust/pull/50808
|
||||
// https://blog.rust-lang.org/2018/08/02/Rust-1.28.html#library-stabilizations
|
||||
if minor >= 28 {
|
||||
println!("cargo:rustc-cfg=num_nonzero");
|
||||
}
|
||||
|
||||
@@ -1313,7 +1313,7 @@ macro_rules! variant_identifier {
|
||||
formatter.write_str($expecting_message)
|
||||
}
|
||||
|
||||
fn visit_u32<E>(self, value: u32) -> Result<Self::Value, E>
|
||||
fn visit_u64<E>(self, value: u64) -> Result<Self::Value, E>
|
||||
where
|
||||
E: Error,
|
||||
{
|
||||
@@ -1321,7 +1321,7 @@ macro_rules! variant_identifier {
|
||||
$(
|
||||
$index => Ok($name_kind :: $variant),
|
||||
)*
|
||||
_ => Err(Error::invalid_value(Unexpected::Unsigned(value as u64), &self),),
|
||||
_ => Err(Error::invalid_value(Unexpected::Unsigned(value), &self),),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2326,7 +2326,7 @@ where
|
||||
formatter.write_str("`Unbounded`, `Included` or `Excluded`")
|
||||
}
|
||||
|
||||
fn visit_u32<E>(self, value: u32) -> Result<Self::Value, E>
|
||||
fn visit_u64<E>(self, value: u64) -> Result<Self::Value, E>
|
||||
where
|
||||
E: Error,
|
||||
{
|
||||
@@ -2335,7 +2335,7 @@ where
|
||||
1 => Ok(Field::Included),
|
||||
2 => Ok(Field::Excluded),
|
||||
_ => Err(Error::invalid_value(
|
||||
Unexpected::Unsigned(value as u64),
|
||||
Unexpected::Unsigned(value),
|
||||
&self,
|
||||
)),
|
||||
}
|
||||
@@ -2492,7 +2492,7 @@ where
|
||||
formatter.write_str("`Ok` or `Err`")
|
||||
}
|
||||
|
||||
fn visit_u32<E>(self, value: u32) -> Result<Self::Value, E>
|
||||
fn visit_u64<E>(self, value: u64) -> Result<Self::Value, E>
|
||||
where
|
||||
E: Error,
|
||||
{
|
||||
@@ -2500,7 +2500,7 @@ where
|
||||
0 => Ok(Field::Ok),
|
||||
1 => Ok(Field::Err),
|
||||
_ => Err(Error::invalid_value(
|
||||
Unexpected::Unsigned(value as u64),
|
||||
Unexpected::Unsigned(value),
|
||||
&self,
|
||||
)),
|
||||
}
|
||||
|
||||
+1
-1
@@ -104,7 +104,7 @@
|
||||
//! [`Deserialize`]: ../trait.Deserialize.html
|
||||
//! [`Deserializer`]: ../trait.Deserializer.html
|
||||
//! [`LinkedHashMap<K, V>`]: https://docs.rs/linked-hash-map/*/linked_hash_map/struct.LinkedHashMap.html
|
||||
//! [`bincode`]: https://github.com/TyOverby/bincode
|
||||
//! [`bincode`]: https://github.com/servo/bincode
|
||||
//! [`linked-hash-map`]: https://crates.io/crates/linked-hash-map
|
||||
//! [`serde_derive`]: https://crates.io/crates/serde_derive
|
||||
//! [`serde_json`]: https://github.com/serde-rs/json
|
||||
|
||||
@@ -1034,7 +1034,7 @@ where
|
||||
let value = self.value.take();
|
||||
// Panic because this indicates a bug in the program rather than an
|
||||
// expected failure.
|
||||
let value = value.expect("MapAccess::visit_value called before visit_key");
|
||||
let value = value.expect("MapAccess::next_value called before next_key");
|
||||
seed.deserialize(value.into_deserializer())
|
||||
}
|
||||
|
||||
|
||||
+11
-7
@@ -37,8 +37,8 @@
|
||||
//! used for IPC within the Servo rendering engine.
|
||||
//! - [CBOR], a Concise Binary Object Representation designed for small message
|
||||
//! size without the need for version negotiation.
|
||||
//! - [YAML], a popular human-friendly configuration language that ain't markup
|
||||
//! language.
|
||||
//! - [YAML], a self-proclaimed human-friendly configuration language that ain't
|
||||
//! markup language.
|
||||
//! - [MessagePack], an efficient binary format that resembles a compact JSON.
|
||||
//! - [TOML], a minimal configuration format used by [Cargo].
|
||||
//! - [Pickle], a format common in the Python world.
|
||||
@@ -48,7 +48,7 @@
|
||||
//! definition.
|
||||
//! - [JSON5], A superset of JSON including some productions from ES5.
|
||||
//! - [Postcard], a no\_std and embedded-systems friendly compact binary format.
|
||||
//! - [URL], the x-www-form-urlencoded format.
|
||||
//! - [URL] query strings, in the x-www-form-urlencoded format.
|
||||
//! - [Envy], a way to deserialize environment variables into Rust structs.
|
||||
//! *(deserialization only)*
|
||||
//! - [Envy Store], a way to deserialize [AWS Parameter Store] parameters into
|
||||
@@ -56,9 +56,10 @@
|
||||
//! - [S-expressions], the textual representation of code and data used by the
|
||||
//! Lisp language family.
|
||||
//! - [D-Bus]'s binary wire format.
|
||||
//! - [FlexBuffers], the schemaless cousin of Google's FlatBuffers zero-copy serialization format.
|
||||
//!
|
||||
//! [JSON]: https://github.com/serde-rs/json
|
||||
//! [Bincode]: https://github.com/TyOverby/bincode
|
||||
//! [Bincode]: https://github.com/servo/bincode
|
||||
//! [CBOR]: https://github.com/pyfisch/cbor
|
||||
//! [YAML]: https://github.com/dtolnay/serde-yaml
|
||||
//! [MessagePack]: https://github.com/3Hren/msgpack-rust
|
||||
@@ -69,25 +70,26 @@
|
||||
//! [Avro]: https://github.com/flavray/avro-rs
|
||||
//! [JSON5]: https://github.com/callum-oakley/json5-rs
|
||||
//! [Postcard]: https://github.com/jamesmunns/postcard
|
||||
//! [URL]: https://github.com/nox/serde_urlencoded
|
||||
//! [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
|
||||
//! [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
|
||||
//! [FlexBuffers]: https://github.com/google/flatbuffers/tree/master/rust/flexbuffers
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Serde types in rustdoc of other crates get linked to here.
|
||||
#![doc(html_root_url = "https://docs.rs/serde/1.0.112")]
|
||||
#![doc(html_root_url = "https://docs.rs/serde/1.0.117")]
|
||||
// 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
|
||||
// discussion of these features please refer to this issue:
|
||||
//
|
||||
// https://github.com/serde-rs/serde/issues/812
|
||||
#![cfg_attr(feature = "unstable", feature(specialization, never_type))]
|
||||
#![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))]
|
||||
@@ -109,12 +111,14 @@
|
||||
// things are often more readable this way
|
||||
cast_lossless,
|
||||
module_name_repetitions,
|
||||
option_if_let_else,
|
||||
single_match_else,
|
||||
type_complexity,
|
||||
use_self,
|
||||
zero_prefixed_literal,
|
||||
// correctly used
|
||||
enum_glob_use,
|
||||
map_err_ignore,
|
||||
wildcard_imports,
|
||||
// not practical
|
||||
needless_pass_by_value,
|
||||
|
||||
@@ -2763,6 +2763,13 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
fn deserialize_unit<V>(self, visitor: V) -> Result<V::Value, Self::Error>
|
||||
where
|
||||
V: Visitor<'de>,
|
||||
{
|
||||
visitor.visit_unit()
|
||||
}
|
||||
|
||||
forward_to_deserialize_other! {
|
||||
deserialize_bool()
|
||||
deserialize_i8()
|
||||
@@ -2780,7 +2787,6 @@ where
|
||||
deserialize_string()
|
||||
deserialize_bytes()
|
||||
deserialize_byte_buf()
|
||||
deserialize_unit()
|
||||
deserialize_unit_struct(&'static str)
|
||||
deserialize_seq()
|
||||
deserialize_tuple(usize)
|
||||
|
||||
@@ -1124,7 +1124,7 @@ where
|
||||
}
|
||||
|
||||
fn serialize_unit(self) -> Result<Self::Ok, Self::Error> {
|
||||
Err(Self::bad_type(Unsupported::Unit))
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn serialize_unit_struct(self, _: &'static str) -> Result<Self::Ok, Self::Error> {
|
||||
|
||||
@@ -753,10 +753,10 @@ impl Serialize for net::SocketAddrV6 {
|
||||
S: Serializer,
|
||||
{
|
||||
if serializer.is_human_readable() {
|
||||
const MAX_LEN: usize = 47;
|
||||
const MAX_LEN: usize = 58;
|
||||
debug_assert_eq!(
|
||||
MAX_LEN,
|
||||
"[1001:1002:1003:1004:1005:1006:1007:1008]:65000".len()
|
||||
"[1001:1002:1003:1004:1005:1006:1007:1008%4294967295]:65000".len()
|
||||
);
|
||||
serialize_display_bounded_length!(self, MAX_LEN, serializer)
|
||||
} else {
|
||||
|
||||
+3
-32
@@ -99,7 +99,7 @@
|
||||
//! [`LinkedHashMap<K, V>`]: https://docs.rs/linked-hash-map/*/linked_hash_map/struct.LinkedHashMap.html
|
||||
//! [`Serialize`]: ../trait.Serialize.html
|
||||
//! [`Serializer`]: ../trait.Serializer.html
|
||||
//! [`bincode`]: https://github.com/TyOverby/bincode
|
||||
//! [`bincode`]: https://github.com/servo/bincode
|
||||
//! [`linked-hash-map`]: https://crates.io/crates/linked-hash-map
|
||||
//! [`serde_derive`]: https://crates.io/crates/serde_derive
|
||||
//! [`serde_json`]: https://github.com/serde-rs/json
|
||||
@@ -1278,7 +1278,7 @@ pub trait Serializer: Sized {
|
||||
<I as IntoIterator>::Item: Serialize,
|
||||
{
|
||||
let iter = iter.into_iter();
|
||||
let mut serializer = try!(self.serialize_seq(iter.len_hint()));
|
||||
let mut serializer = try!(self.serialize_seq(iterator_len_hint(&iter)));
|
||||
for item in iter {
|
||||
try!(serializer.serialize_element(&item));
|
||||
}
|
||||
@@ -1318,7 +1318,7 @@ pub trait Serializer: Sized {
|
||||
I: IntoIterator<Item = (K, V)>,
|
||||
{
|
||||
let iter = iter.into_iter();
|
||||
let mut serializer = try!(self.serialize_map(iter.len_hint()));
|
||||
let mut serializer = try!(self.serialize_map(iterator_len_hint(&iter)));
|
||||
for (key, value) in iter {
|
||||
try!(serializer.serialize_entry(&key, &value));
|
||||
}
|
||||
@@ -1953,35 +1953,6 @@ pub trait SerializeStructVariant {
|
||||
fn end(self) -> Result<Self::Ok, Self::Error>;
|
||||
}
|
||||
|
||||
trait LenHint: Iterator {
|
||||
fn len_hint(&self) -> Option<usize>;
|
||||
}
|
||||
|
||||
impl<I> LenHint for I
|
||||
where
|
||||
I: Iterator,
|
||||
{
|
||||
#[cfg(not(feature = "unstable"))]
|
||||
fn len_hint(&self) -> Option<usize> {
|
||||
iterator_len_hint(self)
|
||||
}
|
||||
|
||||
#[cfg(feature = "unstable")]
|
||||
default fn len_hint(&self) -> Option<usize> {
|
||||
iterator_len_hint(self)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "unstable")]
|
||||
impl<I> LenHint for I
|
||||
where
|
||||
I: ExactSizeIterator,
|
||||
{
|
||||
fn len_hint(&self) -> Option<usize> {
|
||||
Some(self.len())
|
||||
}
|
||||
}
|
||||
|
||||
fn iterator_len_hint<I>(iter: &I) -> Option<usize>
|
||||
where
|
||||
I: Iterator,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "serde_derive"
|
||||
version = "1.0.112" # remember to update html_root_url
|
||||
version = "1.0.117" # remember to update html_root_url
|
||||
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>", "David Tolnay <dtolnay@gmail.com>"]
|
||||
license = "MIT OR Apache-2.0"
|
||||
description = "Macros 1.1 implementation of #[derive(Serialize, Deserialize)]"
|
||||
@@ -9,7 +9,7 @@ repository = "https://github.com/serde-rs/serde"
|
||||
documentation = "https://serde.rs/derive.html"
|
||||
keywords = ["serde", "serialization", "no_std"]
|
||||
readme = "crates-io.md"
|
||||
include = ["src/**/*.rs", "crates-io.md", "README.md", "LICENSE-APACHE", "LICENSE-MIT"]
|
||||
include = ["build.rs", "src/**/*.rs", "crates-io.md", "README.md", "LICENSE-APACHE", "LICENSE-MIT"]
|
||||
|
||||
[features]
|
||||
default = []
|
||||
@@ -22,7 +22,7 @@ proc-macro = true
|
||||
[dependencies]
|
||||
proc-macro2 = "1.0"
|
||||
quote = "1.0"
|
||||
syn = { version = "1.0", features = ["visit"] }
|
||||
syn = { version = "1.0.33", features = ["visit"] }
|
||||
|
||||
[dev-dependencies]
|
||||
serde = { version = "1.0", path = "../serde" }
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
use std::env;
|
||||
use std::process::Command;
|
||||
use std::str;
|
||||
|
||||
// The rustc-cfg strings below are *not* public API. Please let us know by
|
||||
// opening a GitHub issue if your build environment requires some way to enable
|
||||
// these cfgs other than by executing our build script.
|
||||
fn main() {
|
||||
let minor = match rustc_minor_version() {
|
||||
Some(minor) => minor,
|
||||
None => return,
|
||||
};
|
||||
|
||||
// Underscore const names stabilized in Rust 1.37:
|
||||
// https://blog.rust-lang.org/2019/08/15/Rust-1.37.0.html#using-unnamed-const-items-for-macros
|
||||
if minor >= 37 {
|
||||
println!("cargo:rustc-cfg=underscore_consts");
|
||||
}
|
||||
}
|
||||
|
||||
fn rustc_minor_version() -> Option<u32> {
|
||||
let rustc = env::var_os("RUSTC")?;
|
||||
let output = Command::new(rustc).arg("--version").output().ok()?;
|
||||
let version = str::from_utf8(&output.stdout).ok()?;
|
||||
let mut pieces = version.split('.');
|
||||
if pieces.next() != Some("rustc 1") {
|
||||
return None;
|
||||
}
|
||||
pieces.next()?.parse().ok()
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
use proc_macro2::{Ident, Span, TokenStream};
|
||||
use proc_macro2::{Ident, TokenStream};
|
||||
use quote::format_ident;
|
||||
|
||||
use syn;
|
||||
use try;
|
||||
@@ -11,10 +12,11 @@ pub fn wrap_in_const(
|
||||
) -> TokenStream {
|
||||
let try_replacement = try::replacement();
|
||||
|
||||
let dummy_const = Ident::new(
|
||||
&format!("_IMPL_{}_FOR_{}", trait_, unraw(ty)),
|
||||
Span::call_site(),
|
||||
);
|
||||
let dummy_const = if cfg!(underscore_consts) {
|
||||
format_ident!("_")
|
||||
} else {
|
||||
format_ident!("_IMPL_{}_FOR_{}", trait_, unraw(ty))
|
||||
};
|
||||
|
||||
let use_serde = match serde_path {
|
||||
Some(path) => quote! {
|
||||
|
||||
@@ -597,7 +597,11 @@ impl Container {
|
||||
for attr in &item.attrs {
|
||||
if attr.path.is_ident("repr") {
|
||||
let _ = attr.parse_args_with(|input: ParseStream| {
|
||||
is_packed |= input.parse::<Ident>()? == "packed";
|
||||
while let Some(token) = input.parse()? {
|
||||
if let TokenTree::Ident(ident) = token {
|
||||
is_packed |= ident == "packed";
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
});
|
||||
}
|
||||
|
||||
@@ -13,13 +13,14 @@
|
||||
//!
|
||||
//! [https://serde.rs/derive.html]: https://serde.rs/derive.html
|
||||
|
||||
#![doc(html_root_url = "https://docs.rs/serde_derive/1.0.112")]
|
||||
#![doc(html_root_url = "https://docs.rs/serde_derive/1.0.117")]
|
||||
#![allow(unknown_lints, bare_trait_objects)]
|
||||
#![deny(clippy::all, clippy::pedantic)]
|
||||
// Ignored clippy lints
|
||||
#![allow(
|
||||
clippy::cognitive_complexity,
|
||||
clippy::enum_variant_names,
|
||||
clippy::match_like_matches_macro,
|
||||
clippy::needless_pass_by_value,
|
||||
clippy::too_many_arguments,
|
||||
clippy::trivially_copy_pass_by_ref,
|
||||
@@ -37,9 +38,11 @@
|
||||
clippy::filter_map,
|
||||
clippy::indexing_slicing,
|
||||
clippy::items_after_statements,
|
||||
clippy::map_err_ignore,
|
||||
clippy::match_same_arms,
|
||||
clippy::module_name_repetitions,
|
||||
clippy::must_use_candidate,
|
||||
clippy::option_if_let_else,
|
||||
clippy::similar_names,
|
||||
clippy::single_match_else,
|
||||
clippy::struct_excessive_bools,
|
||||
@@ -48,8 +51,6 @@
|
||||
clippy::use_self,
|
||||
clippy::wildcard_imports
|
||||
)]
|
||||
// The `quote!` macro requires deep recursion.
|
||||
#![recursion_limit = "512"]
|
||||
|
||||
#[macro_use]
|
||||
extern crate quote;
|
||||
|
||||
@@ -16,7 +16,7 @@ path = "lib.rs"
|
||||
[dependencies]
|
||||
proc-macro2 = "1.0"
|
||||
quote = "1.0"
|
||||
syn = { version = "1.0", default-features = false, features = ["derive", "parsing", "printing", "clone-impls"] }
|
||||
syn = { version = "1.0.33", default-features = false, features = ["derive", "parsing", "printing", "clone-impls"] }
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
targets = ["x86_64-unknown-linux-gnu"]
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "serde_test"
|
||||
version = "1.0.112" # remember to update html_root_url
|
||||
version = "1.0.117" # remember to update html_root_url
|
||||
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>", "David Tolnay <dtolnay@gmail.com>"]
|
||||
license = "MIT OR Apache-2.0"
|
||||
description = "Token De/Serializer for testing De/Serialize implementations"
|
||||
|
||||
@@ -144,7 +144,7 @@
|
||||
//! # }
|
||||
//! ```
|
||||
|
||||
#![doc(html_root_url = "https://docs.rs/serde_test/1.0.112")]
|
||||
#![doc(html_root_url = "https://docs.rs/serde_test/1.0.117")]
|
||||
#![cfg_attr(feature = "cargo-clippy", allow(renamed_and_removed_lints))]
|
||||
#![cfg_attr(feature = "cargo-clippy", deny(clippy, clippy_pedantic))]
|
||||
// Ignored clippy lints
|
||||
|
||||
@@ -9,7 +9,7 @@ enum DeEnum<B, C, D> {
|
||||
}
|
||||
#[doc(hidden)]
|
||||
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
||||
const _IMPL_SERIALIZE_FOR_DeEnum: () = {
|
||||
const _: () = {
|
||||
#[allow(rust_2018_idioms, clippy::useless_attribute)]
|
||||
extern crate serde as _serde;
|
||||
#[automatically_derived]
|
||||
@@ -261,7 +261,7 @@ const _IMPL_SERIALIZE_FOR_DeEnum: () = {
|
||||
};
|
||||
#[doc(hidden)]
|
||||
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
||||
const _IMPL_DESERIALIZE_FOR_DeEnum: () = {
|
||||
const _: () = {
|
||||
#[allow(rust_2018_idioms, clippy::useless_attribute)]
|
||||
extern crate serde as _serde;
|
||||
#[automatically_derived]
|
||||
|
||||
@@ -10,7 +10,7 @@ struct DefaultTyParam<T: AssociatedType<X = i32> = i32> {
|
||||
}
|
||||
#[doc(hidden)]
|
||||
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
||||
const _IMPL_SERIALIZE_FOR_DefaultTyParam: () = {
|
||||
const _: () = {
|
||||
#[allow(rust_2018_idioms, clippy::useless_attribute)]
|
||||
extern crate serde as _serde;
|
||||
#[automatically_derived]
|
||||
@@ -45,7 +45,7 @@ const _IMPL_SERIALIZE_FOR_DefaultTyParam: () = {
|
||||
};
|
||||
#[doc(hidden)]
|
||||
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
||||
const _IMPL_DESERIALIZE_FOR_DefaultTyParam: () = {
|
||||
const _: () = {
|
||||
#[allow(rust_2018_idioms, clippy::useless_attribute)]
|
||||
extern crate serde as _serde;
|
||||
#[automatically_derived]
|
||||
|
||||
@@ -7,7 +7,7 @@ pub enum GenericEnum<T, U> {
|
||||
}
|
||||
#[doc(hidden)]
|
||||
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
||||
const _IMPL_SERIALIZE_FOR_GenericEnum: () = {
|
||||
const _: () = {
|
||||
#[allow(rust_2018_idioms, clippy::useless_attribute)]
|
||||
extern crate serde as _serde;
|
||||
#[automatically_derived]
|
||||
@@ -110,7 +110,7 @@ const _IMPL_SERIALIZE_FOR_GenericEnum: () = {
|
||||
};
|
||||
#[doc(hidden)]
|
||||
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
||||
const _IMPL_DESERIALIZE_FOR_GenericEnum: () = {
|
||||
const _: () = {
|
||||
#[allow(rust_2018_idioms, clippy::useless_attribute)]
|
||||
extern crate serde as _serde;
|
||||
#[automatically_derived]
|
||||
|
||||
@@ -4,7 +4,7 @@ pub struct GenericStruct<T> {
|
||||
}
|
||||
#[doc(hidden)]
|
||||
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
||||
const _IMPL_SERIALIZE_FOR_GenericStruct: () = {
|
||||
const _: () = {
|
||||
#[allow(rust_2018_idioms, clippy::useless_attribute)]
|
||||
extern crate serde as _serde;
|
||||
#[automatically_derived]
|
||||
@@ -38,7 +38,7 @@ const _IMPL_SERIALIZE_FOR_GenericStruct: () = {
|
||||
};
|
||||
#[doc(hidden)]
|
||||
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
||||
const _IMPL_DESERIALIZE_FOR_GenericStruct: () = {
|
||||
const _: () = {
|
||||
#[allow(rust_2018_idioms, clippy::useless_attribute)]
|
||||
extern crate serde as _serde;
|
||||
#[automatically_derived]
|
||||
@@ -400,7 +400,7 @@ const _IMPL_DESERIALIZE_FOR_GenericStruct: () = {
|
||||
pub struct GenericNewTypeStruct<T>(T);
|
||||
#[doc(hidden)]
|
||||
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
||||
const _IMPL_SERIALIZE_FOR_GenericNewTypeStruct: () = {
|
||||
const _: () = {
|
||||
#[allow(rust_2018_idioms, clippy::useless_attribute)]
|
||||
extern crate serde as _serde;
|
||||
#[automatically_derived]
|
||||
@@ -422,7 +422,7 @@ const _IMPL_SERIALIZE_FOR_GenericNewTypeStruct: () = {
|
||||
};
|
||||
#[doc(hidden)]
|
||||
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
||||
const _IMPL_DESERIALIZE_FOR_GenericNewTypeStruct: () = {
|
||||
const _: () = {
|
||||
#[allow(rust_2018_idioms, clippy::useless_attribute)]
|
||||
extern crate serde as _serde;
|
||||
#[automatically_derived]
|
||||
|
||||
@@ -2,7 +2,7 @@ use serde::{Deserialize, Serialize};
|
||||
pub struct GenericTupleStruct<T, U>(T, U);
|
||||
#[doc(hidden)]
|
||||
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
||||
const _IMPL_DESERIALIZE_FOR_GenericTupleStruct: () = {
|
||||
const _: () = {
|
||||
#[allow(rust_2018_idioms, clippy::useless_attribute)]
|
||||
extern crate serde as _serde;
|
||||
#[automatically_derived]
|
||||
|
||||
@@ -7,7 +7,7 @@ enum Lifetimes<'a> {
|
||||
}
|
||||
#[doc(hidden)]
|
||||
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
||||
const _IMPL_SERIALIZE_FOR_Lifetimes: () = {
|
||||
const _: () = {
|
||||
#[allow(rust_2018_idioms, clippy::useless_attribute)]
|
||||
extern crate serde as _serde;
|
||||
#[automatically_derived]
|
||||
@@ -91,7 +91,7 @@ const _IMPL_SERIALIZE_FOR_Lifetimes: () = {
|
||||
};
|
||||
#[doc(hidden)]
|
||||
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
||||
const _IMPL_DESERIALIZE_FOR_Lifetimes: () = {
|
||||
const _: () = {
|
||||
#[allow(rust_2018_idioms, clippy::useless_attribute)]
|
||||
extern crate serde as _serde;
|
||||
#[automatically_derived]
|
||||
|
||||
@@ -6,7 +6,7 @@ struct SerNamedMap<'a, 'b, A: 'a, B: 'b, C> {
|
||||
}
|
||||
#[doc(hidden)]
|
||||
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
||||
const _IMPL_SERIALIZE_FOR_SerNamedMap: () = {
|
||||
const _: () = {
|
||||
#[allow(rust_2018_idioms, clippy::useless_attribute)]
|
||||
extern crate serde as _serde;
|
||||
#[automatically_derived]
|
||||
@@ -59,7 +59,7 @@ struct DeNamedMap<A, B, C> {
|
||||
}
|
||||
#[doc(hidden)]
|
||||
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
||||
const _IMPL_DESERIALIZE_FOR_DeNamedMap: () = {
|
||||
const _: () = {
|
||||
#[allow(rust_2018_idioms, clippy::useless_attribute)]
|
||||
extern crate serde as _serde;
|
||||
#[automatically_derived]
|
||||
|
||||
@@ -2,7 +2,7 @@ use serde::{Deserialize, Serialize};
|
||||
struct SerNamedTuple<'a, 'b, A: 'a, B: 'b, C>(&'a A, &'b mut B, C);
|
||||
#[doc(hidden)]
|
||||
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
||||
const _IMPL_SERIALIZE_FOR_SerNamedTuple: () = {
|
||||
const _: () = {
|
||||
#[allow(rust_2018_idioms, clippy::useless_attribute)]
|
||||
extern crate serde as _serde;
|
||||
#[automatically_derived]
|
||||
@@ -51,7 +51,7 @@ const _IMPL_SERIALIZE_FOR_SerNamedTuple: () = {
|
||||
struct DeNamedTuple<A, B, C>(A, B, C);
|
||||
#[doc(hidden)]
|
||||
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
||||
const _IMPL_DESERIALIZE_FOR_DeNamedTuple: () = {
|
||||
const _: () = {
|
||||
#[allow(rust_2018_idioms, clippy::useless_attribute)]
|
||||
extern crate serde as _serde;
|
||||
#[automatically_derived]
|
||||
|
||||
@@ -2,7 +2,7 @@ use serde::{Deserialize, Serialize};
|
||||
struct NamedUnit;
|
||||
#[doc(hidden)]
|
||||
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
||||
const _IMPL_SERIALIZE_FOR_NamedUnit: () = {
|
||||
const _: () = {
|
||||
#[allow(rust_2018_idioms, clippy::useless_attribute)]
|
||||
extern crate serde as _serde;
|
||||
#[automatically_derived]
|
||||
@@ -17,7 +17,7 @@ const _IMPL_SERIALIZE_FOR_NamedUnit: () = {
|
||||
};
|
||||
#[doc(hidden)]
|
||||
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
||||
const _IMPL_DESERIALIZE_FOR_NamedUnit: () = {
|
||||
const _: () = {
|
||||
#[allow(rust_2018_idioms, clippy::useless_attribute)]
|
||||
extern crate serde as _serde;
|
||||
#[automatically_derived]
|
||||
|
||||
@@ -12,7 +12,7 @@ where
|
||||
}
|
||||
#[doc(hidden)]
|
||||
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
||||
const _IMPL_SERIALIZE_FOR_SerEnum: () = {
|
||||
const _: () = {
|
||||
#[allow(rust_2018_idioms, clippy::useless_attribute)]
|
||||
extern crate serde as _serde;
|
||||
#[automatically_derived]
|
||||
|
||||
@@ -2,7 +2,7 @@ use serde::{Deserialize, Serialize};
|
||||
enum Void {}
|
||||
#[doc(hidden)]
|
||||
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
||||
const _IMPL_SERIALIZE_FOR_Void: () = {
|
||||
const _: () = {
|
||||
#[allow(rust_2018_idioms, clippy::useless_attribute)]
|
||||
extern crate serde as _serde;
|
||||
#[automatically_derived]
|
||||
@@ -17,7 +17,7 @@ const _IMPL_SERIALIZE_FOR_Void: () = {
|
||||
};
|
||||
#[doc(hidden)]
|
||||
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
||||
const _IMPL_DESERIALIZE_FOR_Void: () = {
|
||||
const _: () = {
|
||||
#[allow(rust_2018_idioms, clippy::useless_attribute)]
|
||||
extern crate serde as _serde;
|
||||
#[automatically_derived]
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#[cfg_attr(target_os = "emscripten", ignore)]
|
||||
#[cfg_attr(not(expandtest), ignore)]
|
||||
#[rustversion::attr(not(nightly), ignore)]
|
||||
#[allow(unused_attributes)]
|
||||
#[test]
|
||||
fn expandtest() {
|
||||
macrotest::expand("tests/expand/*.rs");
|
||||
|
||||
@@ -1967,6 +1967,29 @@ fn test_flatten_map_twice() {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_flatten_unit() {
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
struct Response<T> {
|
||||
#[serde(flatten)]
|
||||
data: T,
|
||||
status: usize,
|
||||
}
|
||||
|
||||
assert_tokens(
|
||||
&Response {
|
||||
data: (),
|
||||
status: 0,
|
||||
},
|
||||
&[
|
||||
Token::Map { len: None },
|
||||
Token::Str("status"),
|
||||
Token::U64(0),
|
||||
Token::MapEnd,
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_flatten_unsupported_type() {
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
|
||||
@@ -4,7 +4,11 @@
|
||||
|
||||
#![deny(warnings)]
|
||||
#![cfg_attr(feature = "unstable", feature(non_ascii_idents))]
|
||||
#![allow(clippy::trivially_copy_pass_by_ref)]
|
||||
#![allow(
|
||||
unknown_lints,
|
||||
mixed_script_confusables,
|
||||
clippy::trivially_copy_pass_by_ref
|
||||
)]
|
||||
|
||||
use serde::de::DeserializeOwned;
|
||||
use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
||||
|
||||
@@ -1878,3 +1878,31 @@ fn test_internally_tagged_newtype_variant_containing_unit_struct() {
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
#[deny(safe_packed_borrows)]
|
||||
#[test]
|
||||
fn test_packed_struct_can_derive_serialize() {
|
||||
#[derive(Copy, Clone, Serialize)]
|
||||
#[repr(packed, C)]
|
||||
struct PackedC {
|
||||
t: f32,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Serialize)]
|
||||
#[repr(C, packed)]
|
||||
struct CPacked {
|
||||
t: f32,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Serialize)]
|
||||
#[repr(C, packed(2))]
|
||||
struct CPacked2 {
|
||||
t: f32,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Serialize)]
|
||||
#[repr(packed(2), C)]
|
||||
struct Packed2C {
|
||||
t: f32,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user