Compare commits

...

40 Commits

Author SHA1 Message Date
David Tolnay fc3f104c4a Release 1.0.117 2020-10-15 09:49:03 -07:00
David Tolnay 4bec9ffd0f Merge pull request #1906 from Mingun/fix-misprint
Fix misprint in the error message
2020-10-11 12:13:03 -07:00
Mingun e6d2322e68 Fix misprint in the error message 2020-10-12 00:03:21 +05:00
David Tolnay 2b504099e4 Include room for SocketAddrV6 to serialize scope id
https://github.com/rust-lang/rust/pull/77426
2020-10-05 04:02:05 -07:00
David Tolnay be7d0e7eb2 Ignore map_err_ignore Clippy pedantic lint 2020-09-25 21:55:59 -04:00
David Tolnay b539cb45d7 Release 1.0.116 2020-09-11 11:56:19 -07:00
David Tolnay a5490e20e1 Merge pull request #1888 from joshtriplett/fix-enum-deserialization-u64
Fix hand-written enum variant deserializations to allow u64 discriminant
2020-09-11 11:55:35 -07:00
Josh Triplett 45c45e87bf Fix hand-written enum variant deserializations to allow u64 discriminant
Automatically generated enum variant deserializers allowed any integer
type as the discriminant, but the hand-written ones for specific enum
types such as Result or IpAddr only allowed types up to u32. This broke
some non-human-readable deserializers for these enums, with
deserializers that emit any integer type as a u64. Switch the visit_u32
methods to visit_u64 methods to allow discriminants to have any size up
to a u64.
2020-09-10 23:24:33 -07:00
David Tolnay 2e76f7013f Update code of conduct link 2020-09-05 13:09:37 -07:00
David Tolnay d35de19120 Merge pull request #1885 from dtolnay/qs
Replace serde_urlencoded link with serde_qs
2020-09-05 10:35:12 -07:00
David Tolnay e5b3507145 Replace serde_urlencoded link with serde_qs 2020-09-05 10:26:36 -07:00
David Tolnay 7ea7c2ceb9 Merge pull request #1882 from dtolnay/bincode
Rename TyOverby/bincode to servo/bincode
2020-08-28 15:43:00 -07:00
David Tolnay 2b5b15967e Rename TyOverby/bincode to servo/bincode 2020-08-28 15:36:51 -07:00
David Tolnay 2ef60b62ac Release 1.0.115 2020-08-10 15:51:19 -07:00
David Tolnay e6f086d85e Merge pull request #1874 from dtolnay/flatunit
Support flattening a Unit
2020-08-10 15:50:30 -07:00
David Tolnay bf76f50294 Support deserializing flattened unit 2020-08-10 15:06:52 -07:00
David Tolnay ba07075590 Support serializing flattened unit 2020-08-10 15:06:47 -07:00
David Tolnay 26186bddd1 Add test for flattened unit 2020-08-10 15:06:34 -07:00
David Tolnay 53b9871b17 Quote no longer requires high recursion 2020-07-16 10:49:16 -07:00
David Tolnay f8787c3ca8 Suppress match_like_matches_macro clippy lint 2020-07-14 18:57:26 -07:00
David Tolnay 3022064f84 Suppress option_if_let_else clippy pedantic lint 2020-07-14 18:57:24 -07:00
David Tolnay 9e140a2071 Tweak yaml format blurb 2020-07-05 20:00:33 -07:00
David Tolnay 24e6acbfae Drop 'help or discussion' issue template
Per https://github.com/serde-rs/serde#getting-help we're steering these
to Discord / Stack Overflow / Reddit / etc.

Can reconsider when GitHub Discussions is out of beta
(https://github.com/vercel/next.js/discussions).
2020-07-04 20:44:22 -07:00
David Tolnay 29c5a50935 Suppress unused_attributes warning in test suite
This test has multiple #[ignore] attributes in some configurations.

    $ cargo +beta check --test expandtest
    warning: unused attribute
     --> test_suite/tests/expandtest.rs:2:29
      |
    2 | #[cfg_attr(not(expandtest), ignore)]
      |                             ^^^^^^
      |
      = note: `#[warn(unused_attributes)]` on by default
2020-06-26 21:37:30 -07:00
David Tolnay c619b2a7c4 Suppress unknown_lints warning in test suite
When building with beta and older rustc:

    error: unknown lint: `mixed_script_confusables`
     --> test_suite/tests/test_gen.rs:7:10
      |
    7 | #![allow(mixed_script_confusables, clippy::trivially_copy_pass_by_ref)]
      |          ^^^^^^^^^^^^^^^^^^^^^^^^
      |
    note: the lint level is defined here
     --> test_suite/tests/test_gen.rs:5:9
      |
    5 | #![deny(warnings)]
      |         ^^^^^^^^
      = note: `#[deny(unknown_lints)]` implied by `#[deny(warnings)]`
2020-06-26 21:37:26 -07:00
David Tolnay 764ebd9b17 Suppress mixed_script_confusables in test suite
error: The usage of Script Group `Greek` in this crate consists solely of mixed script confusables
       --> test_suite/tests/test_gen.rs:269:9
        |
    269 |         σ: f64,
        |         ^
        |
    note: the lint level is defined here
       --> test_suite/tests/test_gen.rs:5:9
        |
    5   | #![deny(warnings)]
        |         ^^^^^^^^
        = note: `#[deny(mixed_script_confusables)]` implied by `#[deny(warnings)]`
        = note: The usage includes 'σ' (U+03C3).
        = note: Please recheck to make sure their usages are indeed what you want.
2020-06-26 19:06:13 -07:00
David Tolnay 9c6f0c3a0e Release 1.0.114 2020-06-21 17:31:02 -07:00
David Tolnay a9f8ea0a1e Simplify search for packed repr attr 2020-06-21 17:22:07 -07:00
David Tolnay 04faac962a Remove error_on_line_overflow rustfmt setting
No longer seeing warnings on this from rustfmt.
2020-06-21 16:48:22 -07:00
Tanner Rogalsky 7e5701ad2b add alignment specific packed repr tests 2020-06-21 16:46:27 -07:00
Tanner Rogalsky 1cd10a7d09 Improved packed repr matching. 2020-06-21 16:46:27 -07:00
Tanner Rogalsky d5e6436b28 Add tests validating Serialize derivation for packed structs. 2020-06-21 16:46:27 -07:00
David Tolnay 8ff11dc234 Merge pull request #1841 from dtolnay/lenhint
Remove len hint specialization
2020-06-20 19:08:34 -07:00
David Tolnay 6b3777b617 Remove len hint specialization 2020-06-20 19:02:26 -07:00
David Tolnay 7350b58f5c Release 1.0.113 2020-06-19 13:31:38 -07:00
David Tolnay 7351e0e55a Link to feature announcements where available 2020-06-19 13:30:14 -07:00
David Tolnay b3ff7e43ef Merge pull request #1827 from taiki-e/underscore_consts
Use underscore consts on Rust 1.37+
2020-06-19 13:27:33 -07:00
Taiki Endo a50e1c20e9 Use underscore consts on Rust 1.37+ 2020-06-19 15:55:43 +09:00
David Tolnay 6980727d74 Merge pull request #1840 from rw/patch-1
Add FlexBuffers to serde ecosystem list
2020-06-18 22:57:59 -07:00
Robert Winslow bb1dedf04d Add FlexBuffers to serde ecosystem list
Add FlexBuffers to serde ecosystem list
2020-06-16 13:36:14 -07:00
37 changed files with 167 additions and 101 deletions
-7
View File
@@ -1,7 +0,0 @@
---
name: Help or discussion
about: This is the right place
---
+1 -1
View File
@@ -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
View File
@@ -1 +0,0 @@
error_on_line_overflow = false
+2 -2
View File
@@ -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
View File
@@ -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");
}
+6 -6
View File
@@ -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
View File
@@ -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
+1 -1
View File
@@ -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
View File
@@ -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,
+7 -1
View File
@@ -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)
+1 -1
View File
@@ -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> {
+2 -2
View File
@@ -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
View File
@@ -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,
+3 -3
View File
@@ -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" }
+30
View File
@@ -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()
}
+7 -5
View File
@@ -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! {
+5 -1
View File
@@ -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(())
});
}
+4 -3
View File
@@ -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;
+1 -1
View File
@@ -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 -1
View File
@@ -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"
+1 -1
View File
@@ -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
+2 -2
View File
@@ -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]
+1 -1
View File
@@ -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 -2
View File
@@ -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
View File
@@ -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");
+23
View File
@@ -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)]
+5 -1
View File
@@ -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};
+28
View File
@@ -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,
}
}