Compare commits

..

4 Commits

Author SHA1 Message Date
David Tolnay 4b622f6bbf Release 1.0.138 2022-07-01 20:09:56 -07:00
David Tolnay 0ee71c70af Ignore explicit_auto_deref clippy lint
error: deref which would be done by auto-deref
        --> serde/src/de/impls.rs:2014:59
         |
    2014 | ...                   Err(Error::unknown_field(&*value, FIELDS))
         |                                                 ^^^^^^ help: try this: `value`
         |
         = note: `-D clippy::explicit-auto-deref` implied by `-D clippy::all`
         = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#explicit_auto_deref

    error: deref which would be done by auto-deref
        --> serde/src/de/impls.rs:2354:55
         |
    2354 | ...                   Err(Error::unknown_field(&*value, FIELDS))
         |                                                 ^^^^^^ help: try this: `value`
         |
         = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#explicit_auto_deref
2022-07-01 19:41:14 -07:00
David Tolnay 6c098e497e Merge pull request #2240 from Kixunil/patch-1
Call `reserve()` in `DeserializeSeed` example
2022-06-30 09:39:25 -07:00
Martin Habovštiak 41ffa6df7e Call reserve() in DeserializeSeed example
This suggests calling `reserve()` in example code so that people who ~blindly copy it get faster code.
2022-06-30 18:28:52 +02:00
26 changed files with 39 additions and 86 deletions
+1
View File
@@ -1,6 +1,7 @@
[workspace]
members = [
"serde",
"serde_derive",
"serde_derive_internals",
"serde_test",
"test_suite",
+2 -2
View File
@@ -1,6 +1,6 @@
[package]
name = "serde"
version = "1.0.137" # remember to update html_root_url and serde_derive dependency
version = "1.0.138" # 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.13"
license = "MIT OR Apache-2.0"
@@ -15,7 +15,7 @@ include = ["build.rs", "src/**/*.rs", "crates-io.md", "README.md", "LICENSE-APAC
build = "build.rs"
[dependencies]
serde_derive = { version = "=1.0.137", optional = true, path = "../serde_derive" }
serde_derive = { version = "=1.0.138", optional = true, path = "../serde_derive" }
[dev-dependencies]
serde_derive = { version = "1.0", path = "../serde_derive" }
+5
View File
@@ -708,6 +708,11 @@ impl<T> DeserializeOwned for T where T: for<'de> Deserialize<'de> {}
/// where
/// A: SeqAccess<'de>,
/// {
/// // Decrease the number of reallocations if there are many elements
/// if let Some(size_hint) = seq.size_hint() {
/// self.0.reserve(size_hint);
/// }
///
/// // Visit each element in the inner array and push it onto
/// // the existing vector.
/// while let Some(elem) = seq.next_element()? {
+2 -1
View File
@@ -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.137")]
#![doc(html_root_url = "https://docs.rs/serde/1.0.138")]
// 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
@@ -120,6 +120,7 @@
// correctly used
derive_partial_eq_without_eq,
enum_glob_use,
explicit_auto_deref,
let_underscore_drop,
map_err_ignore,
result_unit_err,
+3 -7
View File
@@ -1,6 +1,6 @@
[package]
name = "serde_derive"
version = "1.0.137" # remember to update html_root_url
version = "1.0.138" # 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"
@@ -17,7 +17,8 @@ default = []
deserialize_in_place = []
[lib]
crate-type = ["cdylib"]
name = "serde_derive"
proc-macro = true
[dependencies]
proc-macro2 = "1.0"
@@ -29,8 +30,3 @@ serde = { version = "1.0", path = "../serde" }
[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]
[workspace]
[patch.crates-io]
proc-macro2 = { git = "https://github.com/dtolnay/watt" }
+16 -19
View File
@@ -13,7 +13,7 @@
//!
//! [https://serde.rs/derive.html]: https://serde.rs/derive.html
#![doc(html_root_url = "https://docs.rs/serde_derive/1.0.137")]
#![doc(html_root_url = "https://docs.rs/serde_derive/1.0.138")]
#![allow(unknown_lints, bare_trait_objects)]
// Ignored clippy lints
#![allow(
@@ -68,11 +68,12 @@ extern crate quote;
#[macro_use]
extern crate syn;
extern crate proc_macro;
extern crate proc_macro2;
mod internals;
use proc_macro2::TokenStream;
use proc_macro::TokenStream;
use syn::DeriveInput;
#[macro_use]
@@ -86,27 +87,23 @@ mod pretend;
mod ser;
mod try;
#[no_mangle]
pub extern "C" fn derive_serialize(input: TokenStream) -> TokenStream {
let mut input: DeriveInput = match syn::parse2(input) {
Ok(input) => input,
Err(err) => return err.to_compile_error(),
};
ser::expand_derive_serialize(&mut input).unwrap_or_else(to_compile_errors)
#[proc_macro_derive(Serialize, attributes(serde))]
pub fn derive_serialize(input: TokenStream) -> TokenStream {
let mut input = parse_macro_input!(input as DeriveInput);
ser::expand_derive_serialize(&mut input)
.unwrap_or_else(to_compile_errors)
.into()
}
#[no_mangle]
pub extern "C" fn derive_deserialize(input: TokenStream) -> TokenStream {
let mut input: DeriveInput = match syn::parse2(input) {
Ok(input) => input,
Err(err) => return err.to_compile_error(),
};
de::expand_derive_deserialize(&mut input).unwrap_or_else(to_compile_errors)
#[proc_macro_derive(Deserialize, attributes(serde))]
pub fn derive_deserialize(input: TokenStream) -> TokenStream {
let mut input = parse_macro_input!(input as DeriveInput);
de::expand_derive_deserialize(&mut input)
.unwrap_or_else(to_compile_errors)
.into()
}
fn to_compile_errors(errors: Vec<syn::Error>) -> TokenStream {
fn to_compile_errors(errors: Vec<syn::Error>) -> proc_macro2::TokenStream {
let compile_errors = errors.iter().map(syn::Error::to_compile_error);
quote!(#(#compile_errors)*)
}
+1 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "serde_test"
version = "1.0.137" # remember to update html_root_url
version = "1.0.138" # remember to update html_root_url
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>", "David Tolnay <dtolnay@gmail.com>"]
rust-version = "1.13"
license = "MIT OR Apache-2.0"
+1 -1
View File
@@ -144,7 +144,7 @@
//! # }
//! ```
#![doc(html_root_url = "https://docs.rs/serde_test/1.0.137")]
#![doc(html_root_url = "https://docs.rs/serde_test/1.0.138")]
#![cfg_attr(feature = "cargo-clippy", allow(renamed_and_removed_lints))]
// Ignored clippy lints
#![cfg_attr(feature = "cargo-clippy", allow(float_cmp, needless_doctest_main))]
+2 -4
View File
@@ -21,9 +21,7 @@ fnv = "1.0"
macrotest = "=1.0.9"
prettyplease = "=0.1.14"
rustversion = "1.0"
serde = { path = "../serde", features = ["rc"] }
wa-serde-derive = { path = "../wa-serde-derive" }
serde = { path = "../serde", features = ["rc", "derive"] }
serde_derive = { path = "../serde_derive", features = ["deserialize_in_place"] }
serde_test = { path = "../serde_test" }
trybuild = { version = "1.0.49", features = ["diff"] }
[workspace]
-2
View File
@@ -1,5 +1,3 @@
#![cfg(any())]
#[cfg_attr(target_os = "emscripten", ignore)]
#[rustversion::attr(not(nightly), ignore)]
#[cfg_attr(miri, ignore)]
-1
View File
@@ -11,7 +11,6 @@
use serde::de::{self, MapAccess, Unexpected, Visitor};
use serde::{Deserialize, Deserializer, Serialize, Serializer};
use serde_derive::{Deserialize, Serialize};
use std::collections::{BTreeMap, HashMap};
use std::convert::TryFrom;
-1
View File
@@ -5,7 +5,6 @@
)]
use serde::{Deserialize, Deserializer};
use serde_derive::Deserialize;
use serde_test::{assert_de_tokens, assert_de_tokens_error, Token};
use std::borrow::Cow;
-1
View File
@@ -34,7 +34,6 @@ use std::sync::atomic::{AtomicI64, AtomicU64};
use fnv::FnvHasher;
use serde::de::DeserializeOwned;
use serde::{Deserialize, Deserializer};
use serde_derive::Deserialize;
use serde_test::{assert_de_tokens, Configure, Token};
#[macro_use]
-1
View File
@@ -7,7 +7,6 @@
use serde::de::IntoDeserializer;
use serde::Deserialize;
use serde_derive::Deserialize;
use serde_test::{assert_de_tokens_error, Token};
use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet};
use std::ffi::{CStr, CString};
-1
View File
@@ -2,7 +2,6 @@
// successfully when there are a variety of generics and non-(de)serializable
// types involved.
#![cfg(any())]
#![deny(warnings)]
#![allow(
unknown_lints,
+1 -1
View File
@@ -2,7 +2,7 @@
#![allow(clippy::derive_partial_eq_without_eq)]
use serde_derive::Deserialize;
use serde::Deserialize;
use serde_test::{assert_de_tokens, Token};
#[test]
-1
View File
@@ -5,7 +5,6 @@ use serde::de::{
DeserializeSeed, EnumAccess, IgnoredAny, IntoDeserializer, VariantAccess, Visitor,
};
use serde::{forward_to_deserialize_any, Deserialize, Deserializer};
use serde_derive::Deserialize;
#[derive(PartialEq, Debug, Deserialize)]
enum Target {
+1 -1
View File
@@ -8,7 +8,7 @@
mod bytes;
use serde_derive::{Deserialize, Serialize};
use serde::{Deserialize, Serialize};
use serde_test::{
assert_de_tokens, assert_de_tokens_error, assert_ser_tokens, assert_tokens, Token,
};
+1 -1
View File
@@ -1,6 +1,6 @@
#![allow(clippy::redundant_field_names)]
use serde_derive::{Deserialize, Serialize};
use serde::{Deserialize, Serialize};
mod remote {
pub struct Unit;
+1 -1
View File
@@ -1,6 +1,6 @@
#![allow(clippy::used_underscore_binding)]
use serde_derive::{Deserialize, Serialize};
use serde::{Deserialize, Serialize};
#[test]
fn test_self() {
+1 -1
View File
@@ -22,7 +22,7 @@ use std::str;
use std::sync::atomic::{AtomicI64, AtomicU64};
use fnv::FnvHasher;
use serde_derive::Serialize;
use serde::Serialize;
use serde_test::{assert_ser_tokens, assert_ser_tokens_error, Configure, Token};
#[macro_use]
+1 -1
View File
@@ -2,7 +2,7 @@
#[test]
fn test_gen_custom_serde() {
#[derive(serde_derive::Serialize, serde_derive::Deserialize)]
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(crate = "fake_serde")]
struct Foo;
-1
View File
@@ -3,7 +3,6 @@
use serde::de::value::{self, MapAccessDeserializer};
use serde::de::{IntoDeserializer, MapAccess, Visitor};
use serde::{Deserialize, Deserializer};
use serde_derive::Deserialize;
use serde_test::{assert_de_tokens, Token};
use std::fmt;
-1
View File
@@ -1 +0,0 @@
*.wasm
-17
View File
@@ -1,17 +0,0 @@
[package]
name = "wa-serde-derive"
version = "0.1.137"
authors = ["David Tolnay <dtolnay@gmail.com>"]
license = "MIT OR Apache-2.0"
description = "serde_derive compiled to wasm"
repository = "https://github.com/dtolnay/watt"
include = ["src"]
[lib]
name = "serde_derive"
proc-macro = true
[dependencies]
watt = "0.4"
[workspace]
-18
View File
@@ -1,18 +0,0 @@
extern crate proc_macro;
extern crate watt;
use proc_macro::TokenStream;
use watt::WasmMacro;
static MACRO: WasmMacro = WasmMacro::new(WASM);
static WASM: &[u8] = include_bytes!("serde_derive.wasm");
#[proc_macro_derive(Serialize, attributes(serde))]
pub fn derive_serialize(input: TokenStream) -> TokenStream {
MACRO.proc_macro_derive("derive_serialize", input)
}
#[proc_macro_derive(Deserialize, attributes(serde))]
pub fn derive_deserialize(input: TokenStream) -> TokenStream {
MACRO.proc_macro_derive("derive_deserialize", input)
}