summaryrefslogtreecommitdiffstats
path: root/vendor/serde_derive
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/serde_derive')
-rw-r--r--vendor/serde_derive/.cargo-checksum.json2
-rw-r--r--vendor/serde_derive/Cargo.toml4
-rw-r--r--vendor/serde_derive/README.md4
-rw-r--r--vendor/serde_derive/build.rs2
-rw-r--r--vendor/serde_derive/crates-io.md2
-rw-r--r--vendor/serde_derive/src/de.rs186
-rw-r--r--vendor/serde_derive/src/internals/check.rs23
-rw-r--r--vendor/serde_derive/src/lib.rs4
-rw-r--r--vendor/serde_derive/src/ser.rs62
-rw-r--r--vendor/serde_derive/src/this.rs32
10 files changed, 195 insertions, 126 deletions
diff --git a/vendor/serde_derive/.cargo-checksum.json b/vendor/serde_derive/.cargo-checksum.json
index 55e1585d8..4f033d7fe 100644
--- a/vendor/serde_derive/.cargo-checksum.json
+++ b/vendor/serde_derive/.cargo-checksum.json
@@ -1 +1 @@
-{"files":{"Cargo.toml":"74849419177cf3d29dc77892c9519708ac38eecd3c2d4e4367de3c171cd2d410","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"23f18e03dc49df91622fe2a76176497404e46ced8a715d9d2b67a7446571cca3","README.md":"7049b88cb7366be0c8e593f3ffffa313803a5b382f35686c542b4a0da3b291f3","build.rs":"c01db20e19c31505b26b9e9a5aff1c5327a7501fc88917f372a9e718edcb50ab","crates-io.md":"5c42406936cf9af6d4cd7fe0ac730c609e82fd3f15a54549518c72d0ded70c29","src/bound.rs":"268b4995a5d0a129dcbd6e32ef11f587bd271df3f6c4f7230ed54bc99f5ce871","src/de.rs":"c5a41016ce15f8176a2d7a8445ba06d2eb8de0863c1fea0dab51c395dd7dccff","src/dummy.rs":"cb154465020973be8ab6079ab8574df46f38fbe028a5561cd6b1a8bfa1a35478","src/fragment.rs":"5548ba65a53d90a296f60c1328a7a7fb040db467f59c2f5210b2fb320457145d","src/internals/ast.rs":"b019865eef92c1ddbb9029423ac22179f132dc655a51c09fb2a42f4aaef172fd","src/internals/attr.rs":"778074380c4e353b77e03aff9edf15fda9e15a0e7ec25cdfc51d79a26636ddef","src/internals/case.rs":"9492f0c5142d7b7e8cd39c86d13a855e5ce4489425adb2b96aed89e1b7851ac0","src/internals/check.rs":"11ea94257d2a2ee2276938a6beb4ae11b74c39225c1e342e6df1e7d2b2924496","src/internals/ctxt.rs":"6fa544ae52914498a62a395818ebdc1b36ac2fb5903c60afb741a864ad559f1c","src/internals/mod.rs":"f32138ff19d57eb00f88ba11f6b015efab2102657804f71ebbf386a3698dad91","src/internals/receiver.rs":"cd125ba4a3dd6250ed4737555c58627bffd630a536cd7223068eed7c10a170d8","src/internals/respan.rs":"899753859c58ce5f532a3ec4584796a52f13ed5a0533191e48c953ba5c1b52ff","src/internals/symbol.rs":"3c9ce461773b7df3bb64d82aa5a0d93052c3bb0e60209db6c0b5c10ee9cfc9cf","src/lib.rs":"82c587dfec75c78b53fc64ab9366f61213f2776cefea256c9eaeb18193c8cbf4","src/pretend.rs":"4aa53bf6c1350fbcfc8c4997f720cde61a8eb3aab73bb8c101b0f0a74901892b","src/ser.rs":"0d99c841f6c7bc9751ab225fe42d1f8b7fe56e36903efcb4ff10bf6e35c390ba","src/try.rs":"b171b0088c23ebf4bfa07ba457881b41ac5e547d55dd16f737ea988d34badf61"},"package":"4f1d362ca8fc9c3e3a7484440752472d68a6caa98f1ab81d99b5dfe517cec852"} \ No newline at end of file
+{"files":{"Cargo.toml":"72ed2b0578c6c4fbbd14ab2062502092990c48f4687a01a4a07d7fdbb6330756","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"23f18e03dc49df91622fe2a76176497404e46ced8a715d9d2b67a7446571cca3","README.md":"3c12b60b6c77a201665344a7612b42392e77ddc3e907f5a14e3f3a4bb6c4692e","build.rs":"d9a0df0c4dd552ff7fd0c3b3828cb1fff4fc4ab15bd98539881929b76b98003b","crates-io.md":"ee22254ee64c3189eef3e707c8d75dc66a8df2a7ee9e518d95238950780ec387","src/bound.rs":"268b4995a5d0a129dcbd6e32ef11f587bd271df3f6c4f7230ed54bc99f5ce871","src/de.rs":"b28c2fcf5214d33ba1dc855b60634db18608a26f39f9f92bbedf62c456fa8d10","src/dummy.rs":"cb154465020973be8ab6079ab8574df46f38fbe028a5561cd6b1a8bfa1a35478","src/fragment.rs":"5548ba65a53d90a296f60c1328a7a7fb040db467f59c2f5210b2fb320457145d","src/internals/ast.rs":"b019865eef92c1ddbb9029423ac22179f132dc655a51c09fb2a42f4aaef172fd","src/internals/attr.rs":"778074380c4e353b77e03aff9edf15fda9e15a0e7ec25cdfc51d79a26636ddef","src/internals/case.rs":"9492f0c5142d7b7e8cd39c86d13a855e5ce4489425adb2b96aed89e1b7851ac0","src/internals/check.rs":"6b84278b034a156784fc56153df3def1660bcfcfde0cd59f8facce1750717c7d","src/internals/ctxt.rs":"6fa544ae52914498a62a395818ebdc1b36ac2fb5903c60afb741a864ad559f1c","src/internals/mod.rs":"f32138ff19d57eb00f88ba11f6b015efab2102657804f71ebbf386a3698dad91","src/internals/receiver.rs":"cd125ba4a3dd6250ed4737555c58627bffd630a536cd7223068eed7c10a170d8","src/internals/respan.rs":"899753859c58ce5f532a3ec4584796a52f13ed5a0533191e48c953ba5c1b52ff","src/internals/symbol.rs":"3c9ce461773b7df3bb64d82aa5a0d93052c3bb0e60209db6c0b5c10ee9cfc9cf","src/lib.rs":"6a80c0114dcf9924cbbbc03f443cfd0d299be9f89ba6c4fdc2867d990aba5063","src/pretend.rs":"4aa53bf6c1350fbcfc8c4997f720cde61a8eb3aab73bb8c101b0f0a74901892b","src/ser.rs":"8f9ffe1d8bcd28bd40e8d94d688547fa1d518cc722d0292f47d951152c406dd9","src/this.rs":"a2c128955324c2994ed7cdc3fe4eeceb7ad8a0f9d071665a8378c85c8df64ce2","src/try.rs":"b171b0088c23ebf4bfa07ba457881b41ac5e547d55dd16f737ea988d34badf61"},"package":"af487d118eecd09402d70a5d72551860e788df87b464af30e5ea6a38c75c541e"} \ No newline at end of file
diff --git a/vendor/serde_derive/Cargo.toml b/vendor/serde_derive/Cargo.toml
index dc5abf1b4..6258d9df1 100644
--- a/vendor/serde_derive/Cargo.toml
+++ b/vendor/serde_derive/Cargo.toml
@@ -12,7 +12,7 @@
[package]
rust-version = "1.31"
name = "serde_derive"
-version = "1.0.147"
+version = "1.0.152"
authors = [
"Erick Tryzelaar <erick.tryzelaar@gmail.com>",
"David Tolnay <dtolnay@gmail.com>",
@@ -53,7 +53,7 @@ version = "1.0"
version = "1.0"
[dependencies.syn]
-version = "1.0.90"
+version = "1.0.104"
[dev-dependencies.serde]
version = "1.0"
diff --git a/vendor/serde_derive/README.md b/vendor/serde_derive/README.md
index 79409a3fc..c3f6575ef 100644
--- a/vendor/serde_derive/README.md
+++ b/vendor/serde_derive/README.md
@@ -1,6 +1,6 @@
# Serde &emsp; [![Build Status]][actions] [![Latest Version]][crates.io] [![serde: rustc 1.13+]][Rust 1.13] [![serde_derive: rustc 1.31+]][Rust 1.31]
-[Build Status]: https://img.shields.io/github/workflow/status/serde-rs/serde/CI/master
+[Build Status]: https://img.shields.io/github/actions/workflow/status/serde-rs/serde/ci.yml?branch=master
[actions]: https://github.com/serde-rs/serde/actions?query=branch%3Amaster
[Latest Version]: https://img.shields.io/crates/v/serde.svg
[crates.io]: https://crates.io/crates/serde
@@ -19,7 +19,7 @@ You may be looking for:
- [Data formats supported by Serde](https://serde.rs/#data-formats)
- [Setting up `#[derive(Serialize, Deserialize)]`](https://serde.rs/derive.html)
- [Examples](https://serde.rs/examples.html)
-- [API documentation](https://docs.serde.rs/serde/)
+- [API documentation](https://docs.rs/serde)
- [Release notes](https://github.com/serde-rs/serde/releases)
## Serde in action
diff --git a/vendor/serde_derive/build.rs b/vendor/serde_derive/build.rs
index 2aece0469..1249dab59 100644
--- a/vendor/serde_derive/build.rs
+++ b/vendor/serde_derive/build.rs
@@ -6,6 +6,8 @@ use std::str;
// opening a GitHub issue if your build environment requires some way to enable
// these cfgs other than by executing our build script.
fn main() {
+ println!("cargo:rerun-if-changed=build.rs");
+
let minor = match rustc_minor_version() {
Some(minor) => minor,
None => return,
diff --git a/vendor/serde_derive/crates-io.md b/vendor/serde_derive/crates-io.md
index b57bc5fd0..6e0ec280c 100644
--- a/vendor/serde_derive/crates-io.md
+++ b/vendor/serde_derive/crates-io.md
@@ -10,7 +10,7 @@ You may be looking for:
- [Data formats supported by Serde](https://serde.rs/#data-formats)
- [Setting up `#[derive(Serialize, Deserialize)]`](https://serde.rs/derive.html)
- [Examples](https://serde.rs/examples.html)
-- [API documentation](https://docs.serde.rs/serde/)
+- [API documentation](https://docs.rs/serde)
- [Release notes](https://github.com/serde-rs/serde/releases)
## Serde in action
diff --git a/vendor/serde_derive/src/de.rs b/vendor/serde_derive/src/de.rs
index ff7bc42f4..a703adaf7 100644
--- a/vendor/serde_derive/src/de.rs
+++ b/vendor/serde_derive/src/de.rs
@@ -10,6 +10,7 @@ use fragment::{Expr, Fragment, Match, Stmts};
use internals::ast::{Container, Data, Field, Style, Variant};
use internals::{attr, replace_receiver, ungroup, Ctxt, Derive};
use pretend;
+use this;
use std::collections::BTreeSet;
use std::ptr;
@@ -111,9 +112,13 @@ struct Parameters {
local: syn::Ident,
/// Path to the type the impl is for. Either a single `Ident` for local
- /// types or `some::remote::Ident` for remote types. Does not include
- /// generic parameters.
- this: syn::Path,
+ /// types (does not include generic parameters) or `some::remote::Path` for
+ /// remote types.
+ this_type: syn::Path,
+
+ /// Same as `this_type` but using `::<T>` for generic parameters for use in
+ /// expression position.
+ this_value: syn::Path,
/// Generics including any explicit and inferred bounds for the impl.
generics: syn::Generics,
@@ -133,10 +138,8 @@ struct Parameters {
impl Parameters {
fn new(cont: &Container) -> Self {
let local = cont.ident.clone();
- let this = match cont.attrs.remote() {
- Some(remote) => remote.clone(),
- None => cont.ident.clone().into(),
- };
+ let this_type = this::this_type(cont);
+ let this_value = this::this_value(cont);
let borrowed = borrowed_lifetimes(cont);
let generics = build_generics(cont, &borrowed);
let has_getter = cont.data.has_getter();
@@ -144,7 +147,8 @@ impl Parameters {
Parameters {
local,
- this,
+ this_type,
+ this_value,
generics,
borrowed,
has_getter,
@@ -155,7 +159,7 @@ impl Parameters {
/// Type name to use in error messages and `&'static str` arguments to
/// various Deserializer methods.
fn type_name(&self) -> String {
- self.this.segments.last().unwrap().ident.to_string()
+ self.this_type.segments.last().unwrap().ident.to_string()
}
}
@@ -358,7 +362,7 @@ fn deserialize_transparent(cont: &Container, params: &Parameters) -> Fragment {
Data::Enum(_) => unreachable!(),
};
- let this = &params.this;
+ let this_value = &params.this_value;
let transparent_field = fields.iter().find(|f| f.attrs.transparent()).unwrap();
let path = match transparent_field.attrs.deserialize_with() {
@@ -386,7 +390,7 @@ fn deserialize_transparent(cont: &Container, params: &Parameters) -> Fragment {
quote_block! {
_serde::__private::Result::map(
#path(__deserializer),
- |__transparent| #this { #(#assign),* })
+ |__transparent| #this_value { #(#assign),* })
}
}
@@ -407,7 +411,8 @@ fn deserialize_try_from(type_try_from: &syn::Type) -> Fragment {
}
fn deserialize_unit_struct(params: &Parameters, cattrs: &attr::Container) -> Fragment {
- let this = &params.this;
+ let this_type = &params.this_type;
+ let this_value = &params.this_value;
let type_name = cattrs.name().deserialize_name();
let expecting = format!("unit struct {}", params.type_name());
@@ -417,7 +422,7 @@ fn deserialize_unit_struct(params: &Parameters, cattrs: &attr::Container) -> Fra
struct __Visitor;
impl<'de> _serde::de::Visitor<'de> for __Visitor {
- type Value = #this;
+ type Value = #this_type;
fn expecting(&self, __formatter: &mut _serde::__private::Formatter) -> _serde::__private::fmt::Result {
_serde::__private::Formatter::write_str(__formatter, #expecting)
@@ -428,7 +433,7 @@ fn deserialize_unit_struct(params: &Parameters, cattrs: &attr::Container) -> Fra
where
__E: _serde::de::Error,
{
- _serde::__private::Ok(#this)
+ _serde::__private::Ok(#this_value)
}
}
@@ -443,7 +448,8 @@ fn deserialize_tuple(
cattrs: &attr::Container,
deserializer: Option<TokenStream>,
) -> Fragment {
- let this = &params.this;
+ let this_type = &params.this_type;
+ let this_value = &params.this_value;
let (de_impl_generics, de_ty_generics, ty_generics, where_clause) =
split_with_de_lifetime(params);
let delife = params.borrowed.de_lifetime();
@@ -457,7 +463,7 @@ fn deserialize_tuple(
let local = &params.local;
quote!(#local)
} else {
- quote!(#this)
+ quote!(#this_value)
};
let is_enum = variant_ident.is_some();
@@ -485,7 +491,7 @@ fn deserialize_tuple(
let visitor_expr = quote! {
__Visitor {
- marker: _serde::__private::PhantomData::<#this #ty_generics>,
+ marker: _serde::__private::PhantomData::<#this_type #ty_generics>,
lifetime: _serde::__private::PhantomData,
}
};
@@ -510,12 +516,12 @@ fn deserialize_tuple(
quote_block! {
struct __Visitor #de_impl_generics #where_clause {
- marker: _serde::__private::PhantomData<#this #ty_generics>,
+ marker: _serde::__private::PhantomData<#this_type #ty_generics>,
lifetime: _serde::__private::PhantomData<&#delife ()>,
}
impl #de_impl_generics _serde::de::Visitor<#delife> for __Visitor #de_ty_generics #where_clause {
- type Value = #this #ty_generics;
+ type Value = #this_type #ty_generics;
fn expecting(&self, __formatter: &mut _serde::__private::Formatter) -> _serde::__private::fmt::Result {
_serde::__private::Formatter::write_str(__formatter, #expecting)
@@ -544,7 +550,7 @@ fn deserialize_tuple_in_place(
cattrs: &attr::Container,
deserializer: Option<TokenStream>,
) -> Fragment {
- let this = &params.this;
+ let this_type = &params.this_type;
let (de_impl_generics, de_ty_generics, ty_generics, where_clause) =
split_with_de_lifetime(params);
let delife = params.borrowed.de_lifetime();
@@ -600,7 +606,7 @@ fn deserialize_tuple_in_place(
quote_block! {
struct __Visitor #in_place_impl_generics #where_clause {
- place: &#place_life mut #this #ty_generics,
+ place: &#place_life mut #this_type #ty_generics,
lifetime: _serde::__private::PhantomData<&#delife ()>,
}
@@ -705,9 +711,10 @@ fn deserialize_seq(
};
if params.has_getter {
- let this = &params.this;
+ let this_type = &params.this_type;
+ let (_, ty_generics, _) = params.generics.split_for_impl();
result = quote! {
- _serde::__private::Into::<#this>::into(#result)
+ _serde::__private::Into::<#this_type #ty_generics>::into(#result)
};
}
@@ -801,14 +808,14 @@ fn deserialize_seq_in_place(
}
});
- let this = &params.this;
+ let this_type = &params.this_type;
let (_, ty_generics, _) = params.generics.split_for_impl();
let let_default = match cattrs.default() {
attr::Default::Default => Some(quote!(
- let __default: #this #ty_generics = _serde::__private::Default::default();
+ let __default: #this_type #ty_generics = _serde::__private::Default::default();
)),
attr::Default::Path(path) => Some(quote!(
- let __default: #this #ty_generics = #path();
+ let __default: #this_type #ty_generics = #path();
)),
attr::Default::None => {
// We don't need the default value, to prevent an unused variable warning
@@ -849,9 +856,10 @@ fn deserialize_newtype_struct(
let mut result = quote!(#type_path(__field0));
if params.has_getter {
- let this = &params.this;
+ let this_type = &params.this_type;
+ let (_, ty_generics, _) = params.generics.split_for_impl();
result = quote! {
- _serde::__private::Into::<#this>::into(#result)
+ _serde::__private::Into::<#this_type #ty_generics>::into(#result)
};
}
@@ -901,7 +909,8 @@ fn deserialize_struct(
) -> Fragment {
let is_enum = variant_ident.is_some();
- let this = &params.this;
+ let this_type = &params.this_type;
+ let this_value = &params.this_value;
let (de_impl_generics, de_ty_generics, ty_generics, where_clause) =
split_with_de_lifetime(params);
let delife = params.borrowed.de_lifetime();
@@ -913,7 +922,7 @@ fn deserialize_struct(
let local = &params.local;
quote!(#local)
} else {
- quote!(#this)
+ quote!(#this_value)
};
let type_path = match variant_ident {
@@ -941,7 +950,7 @@ fn deserialize_struct(
let visitor_expr = quote! {
__Visitor {
- marker: _serde::__private::PhantomData::<#this #ty_generics>,
+ marker: _serde::__private::PhantomData::<#this_type #ty_generics>,
lifetime: _serde::__private::PhantomData,
}
};
@@ -993,7 +1002,7 @@ fn deserialize_struct(
let visitor_seed = if is_enum && cattrs.has_flatten() {
Some(quote! {
impl #de_impl_generics _serde::de::DeserializeSeed<#delife> for __Visitor #de_ty_generics #where_clause {
- type Value = #this #ty_generics;
+ type Value = #this_type #ty_generics;
fn deserialize<__D>(self, __deserializer: __D) -> _serde::__private::Result<Self::Value, __D::Error>
where
@@ -1011,12 +1020,12 @@ fn deserialize_struct(
#field_visitor
struct __Visitor #de_impl_generics #where_clause {
- marker: _serde::__private::PhantomData<#this #ty_generics>,
+ marker: _serde::__private::PhantomData<#this_type #ty_generics>,
lifetime: _serde::__private::PhantomData<&#delife ()>,
}
impl #de_impl_generics _serde::de::Visitor<#delife> for __Visitor #de_ty_generics #where_clause {
- type Value = #this #ty_generics;
+ type Value = #this_type #ty_generics;
fn expecting(&self, __formatter: &mut _serde::__private::Formatter) -> _serde::__private::fmt::Result {
_serde::__private::Formatter::write_str(__formatter, #expecting)
@@ -1057,7 +1066,7 @@ fn deserialize_struct_in_place(
return None;
}
- let this = &params.this;
+ let this_type = &params.this_type;
let (de_impl_generics, de_ty_generics, ty_generics, where_clause) =
split_with_de_lifetime(params);
let delife = params.borrowed.de_lifetime();
@@ -1123,7 +1132,7 @@ fn deserialize_struct_in_place(
#field_visitor
struct __Visitor #in_place_impl_generics #where_clause {
- place: &#place_life mut #this #ty_generics,
+ place: &#place_life mut #this_type #ty_generics,
lifetime: _serde::__private::PhantomData<&#delife ()>,
}
@@ -1212,7 +1221,7 @@ fn deserialize_externally_tagged_enum(
variants: &[Variant],
cattrs: &attr::Container,
) -> Fragment {
- let this = &params.this;
+ let this_type = &params.this_type;
let (de_impl_generics, de_ty_generics, ty_generics, where_clause) =
split_with_de_lifetime(params);
let delife = params.borrowed.de_lifetime();
@@ -1266,12 +1275,12 @@ fn deserialize_externally_tagged_enum(
#variant_visitor
struct __Visitor #de_impl_generics #where_clause {
- marker: _serde::__private::PhantomData<#this #ty_generics>,
+ marker: _serde::__private::PhantomData<#this_type #ty_generics>,
lifetime: _serde::__private::PhantomData<&#delife ()>,
}
impl #de_impl_generics _serde::de::Visitor<#delife> for __Visitor #de_ty_generics #where_clause {
- type Value = #this #ty_generics;
+ type Value = #this_type #ty_generics;
fn expecting(&self, __formatter: &mut _serde::__private::Formatter) -> _serde::__private::fmt::Result {
_serde::__private::Formatter::write_str(__formatter, #expecting)
@@ -1292,7 +1301,7 @@ fn deserialize_externally_tagged_enum(
#type_name,
VARIANTS,
__Visitor {
- marker: _serde::__private::PhantomData::<#this #ty_generics>,
+ marker: _serde::__private::PhantomData::<#this_type #ty_generics>,
lifetime: _serde::__private::PhantomData,
},
)
@@ -1354,7 +1363,8 @@ fn deserialize_adjacently_tagged_enum(
tag: &str,
content: &str,
) -> Fragment {
- let this = &params.this;
+ let this_type = &params.this_type;
+ let this_value = &params.this_value;
let (de_impl_generics, de_ty_generics, ty_generics, where_clause) =
split_with_de_lifetime(params);
let delife = params.borrowed.de_lifetime();
@@ -1415,13 +1425,13 @@ fn deserialize_adjacently_tagged_enum(
let arm = match variant.style {
Style::Unit => quote! {
- _serde::__private::Ok(#this::#variant_ident)
+ _serde::__private::Ok(#this_value::#variant_ident)
},
Style::Newtype if variant.attrs.deserialize_with().is_none() => {
let span = variant.original.span();
let func = quote_spanned!(span=> _serde::__private::de::missing_field);
quote! {
- #func(#content).map(#this::#variant_ident)
+ #func(#content).map(#this_value::#variant_ident)
}
}
_ => {
@@ -1513,12 +1523,12 @@ fn deserialize_adjacently_tagged_enum(
struct __Seed #de_impl_generics #where_clause {
field: __Field,
- marker: _serde::__private::PhantomData<#this #ty_generics>,
+ marker: _serde::__private::PhantomData<#this_type #ty_generics>,
lifetime: _serde::__private::PhantomData<&#delife ()>,
}
impl #de_impl_generics _serde::de::DeserializeSeed<#delife> for __Seed #de_ty_generics #where_clause {
- type Value = #this #ty_generics;
+ type Value = #this_type #ty_generics;
fn deserialize<__D>(self, __deserializer: __D) -> _serde::__private::Result<Self::Value, __D::Error>
where
@@ -1531,12 +1541,12 @@ fn deserialize_adjacently_tagged_enum(
}
struct __Visitor #de_impl_generics #where_clause {
- marker: _serde::__private::PhantomData<#this #ty_generics>,
+ marker: _serde::__private::PhantomData<#this_type #ty_generics>,
lifetime: _serde::__private::PhantomData<&#delife ()>,
}
impl #de_impl_generics _serde::de::Visitor<#delife> for __Visitor #de_ty_generics #where_clause {
- type Value = #this #ty_generics;
+ type Value = #this_type #ty_generics;
fn expecting(&self, __formatter: &mut _serde::__private::Formatter) -> _serde::__private::fmt::Result {
_serde::__private::Formatter::write_str(__formatter, #expecting)
@@ -1638,7 +1648,7 @@ fn deserialize_adjacently_tagged_enum(
#type_name,
FIELDS,
__Visitor {
- marker: _serde::__private::PhantomData::<#this #ty_generics>,
+ marker: _serde::__private::PhantomData::<#this_type #ty_generics>,
lifetime: _serde::__private::PhantomData,
},
)
@@ -1707,10 +1717,10 @@ fn deserialize_externally_tagged_variant(
match variant.style {
Style::Unit => {
- let this = &params.this;
+ let this_value = &params.this_value;
quote_block! {
try!(_serde::de::VariantAccess::unit_variant(__variant));
- _serde::__private::Ok(#this::#variant_ident)
+ _serde::__private::Ok(#this_value::#variant_ident)
}
}
Style::Newtype => deserialize_externally_tagged_newtype_variant(
@@ -1749,7 +1759,7 @@ fn deserialize_internally_tagged_variant(
match effective_style(variant) {
Style::Unit => {
- let this = &params.this;
+ let this_value = &params.this_value;
let type_name = params.type_name();
let variant_name = variant.ident.to_string();
let default = variant.fields.get(0).map(|field| {
@@ -1758,7 +1768,7 @@ fn deserialize_internally_tagged_variant(
});
quote_block! {
try!(_serde::Deserializer::deserialize_any(#deserializer, _serde::__private::de::InternallyTaggedUnitVisitor::new(#type_name, #variant_name)));
- _serde::__private::Ok(#this::#variant_ident #default)
+ _serde::__private::Ok(#this_value::#variant_ident #default)
}
}
Style::Newtype => deserialize_untagged_newtype_variant(
@@ -1796,7 +1806,7 @@ fn deserialize_untagged_variant(
match effective_style(variant) {
Style::Unit => {
- let this = &params.this;
+ let this_value = &params.this_value;
let type_name = params.type_name();
let variant_name = variant.ident.to_string();
let default = variant.fields.get(0).map(|field| {
@@ -1808,7 +1818,7 @@ fn deserialize_untagged_variant(
#deserializer,
_serde::__private::de::UntaggedUnitVisitor::new(#type_name, #variant_name)
) {
- _serde::__private::Ok(()) => _serde::__private::Ok(#this::#variant_ident #default),
+ _serde::__private::Ok(()) => _serde::__private::Ok(#this_value::#variant_ident #default),
_serde::__private::Err(__err) => _serde::__private::Err(__err),
}
}
@@ -1843,14 +1853,13 @@ fn deserialize_externally_tagged_newtype_variant(
field: &Field,
cattrs: &attr::Container,
) -> Fragment {
- let this = &params.this;
+ let this_value = &params.this_value;
if field.attrs.skip_deserializing() {
- let this = &params.this;
let default = Expr(expr_is_missing(field, cattrs));
return quote_block! {
try!(_serde::de::VariantAccess::unit_variant(__variant));
- _serde::__private::Ok(#this::#variant_ident(#default))
+ _serde::__private::Ok(#this_value::#variant_ident(#default))
};
}
@@ -1861,7 +1870,7 @@ fn deserialize_externally_tagged_newtype_variant(
let func =
quote_spanned!(span=> _serde::de::VariantAccess::newtype_variant::<#field_ty>);
quote_expr! {
- _serde::__private::Result::map(#func(__variant), #this::#variant_ident)
+ _serde::__private::Result::map(#func(__variant), #this_value::#variant_ident)
}
}
Some(path) => {
@@ -1870,7 +1879,7 @@ fn deserialize_externally_tagged_newtype_variant(
#wrapper
_serde::__private::Result::map(
_serde::de::VariantAccess::newtype_variant::<#wrapper_ty>(__variant),
- |__wrapper| #this::#variant_ident(__wrapper.value))
+ |__wrapper| #this_value::#variant_ident(__wrapper.value))
}
}
}
@@ -1882,20 +1891,20 @@ fn deserialize_untagged_newtype_variant(
field: &Field,
deserializer: &TokenStream,
) -> Fragment {
- let this = &params.this;
+ let this_value = &params.this_value;
let field_ty = field.ty;
match field.attrs.deserialize_with() {
None => {
let span = field.original.span();
let func = quote_spanned!(span=> <#field_ty as _serde::Deserialize>::deserialize);
quote_expr! {
- _serde::__private::Result::map(#func(#deserializer), #this::#variant_ident)
+ _serde::__private::Result::map(#func(#deserializer), #this_value::#variant_ident)
}
}
Some(path) => {
quote_block! {
let __value: _serde::__private::Result<#field_ty, _> = #path(#deserializer);
- _serde::__private::Result::map(__value, #this::#variant_ident)
+ _serde::__private::Result::map(__value, #this_value::#variant_ident)
}
}
}
@@ -1907,7 +1916,7 @@ fn deserialize_generated_identifier(
is_variant: bool,
other_idx: Option<usize>,
) -> Fragment {
- let this = quote!(__Field);
+ let this_value = quote!(__Field);
let field_idents: &Vec<_> = &fields.iter().map(|(_, ident, _)| ident).collect();
let (ignore_variant, fallthrough) = if !is_variant && cattrs.has_flatten() {
@@ -1927,7 +1936,7 @@ fn deserialize_generated_identifier(
};
let visitor_impl = Stmts(deserialize_identifier(
- &this,
+ &this_value,
fields,
is_variant,
fallthrough,
@@ -1982,8 +1991,8 @@ fn deserialize_custom_identifier(
attr::Identifier::No => unreachable!(),
};
- let this = &params.this;
- let this = quote!(#this);
+ let this_type = params.this_type.to_token_stream();
+ let this_value = params.this_value.to_token_stream();
let (ordinary, fallthrough, fallthrough_borrowed) = if let Some(last) = variants.last() {
let last_ident = &last.ident;
@@ -1992,7 +2001,7 @@ fn deserialize_custom_identifier(
// last variant (checked in `check_identifier`), so all preceding
// are ordinary variants.
let ordinary = &variants[..variants.len() - 1];
- let fallthrough = quote!(_serde::__private::Ok(#this::#last_ident));
+ let fallthrough = quote!(_serde::__private::Ok(#this_value::#last_ident));
(ordinary, Some(fallthrough), None)
} else if let Style::Newtype = last.style {
let ordinary = &variants[..variants.len() - 1];
@@ -2002,7 +2011,7 @@ fn deserialize_custom_identifier(
_serde::Deserialize::deserialize(
_serde::__private::de::IdentifierDeserializer::from(#value)
),
- #this::#last_ident)
+ #this_value::#last_ident)
}
};
(
@@ -2050,7 +2059,7 @@ fn deserialize_custom_identifier(
split_with_de_lifetime(params);
let delife = params.borrowed.de_lifetime();
let visitor_impl = Stmts(deserialize_identifier(
- &this,
+ &this_value,
&names_idents,
is_variant,
fallthrough,
@@ -2063,18 +2072,18 @@ fn deserialize_custom_identifier(
#names_const
struct __FieldVisitor #de_impl_generics #where_clause {
- marker: _serde::__private::PhantomData<#this #ty_generics>,
+ marker: _serde::__private::PhantomData<#this_type #ty_generics>,
lifetime: _serde::__private::PhantomData<&#delife ()>,
}
impl #de_impl_generics _serde::de::Visitor<#delife> for __FieldVisitor #de_ty_generics #where_clause {
- type Value = #this #ty_generics;
+ type Value = #this_type #ty_generics;
#visitor_impl
}
let __visitor = __FieldVisitor {
- marker: _serde::__private::PhantomData::<#this #ty_generics>,
+ marker: _serde::__private::PhantomData::<#this_type #ty_generics>,
lifetime: _serde::__private::PhantomData,
};
_serde::Deserializer::deserialize_identifier(__deserializer, __visitor)
@@ -2082,7 +2091,7 @@ fn deserialize_custom_identifier(
}
fn deserialize_identifier(
- this: &TokenStream,
+ this_value: &TokenStream,
fields: &[(String, Ident, Vec<String>)],
is_variant: bool,
fallthrough: Option<TokenStream>,
@@ -2103,11 +2112,11 @@ fn deserialize_identifier(
let constructors: &Vec<_> = &flat_fields
.iter()
- .map(|(_, ident)| quote!(#this::#ident))
+ .map(|(_, ident)| quote!(#this_value::#ident))
.collect();
let main_constructors: &Vec<_> = &fields
.iter()
- .map(|(_, ident, _)| quote!(#this::#ident))
+ .map(|(_, ident, _)| quote!(#this_value::#ident))
.collect();
let expecting = expecting.unwrap_or(if is_variant {
@@ -2621,9 +2630,10 @@ fn deserialize_map(
let mut result = quote!(#struct_path { #(#result),* });
if params.has_getter {
- let this = &params.this;
+ let this_type = &params.this_type;
+ let (_, ty_generics, _) = params.generics.split_for_impl();
result = quote! {
- _serde::__private::Into::<#this>::into(#result)
+ _serde::__private::Into::<#this_type #ty_generics>::into(#result)
};
}
@@ -2803,15 +2813,15 @@ fn deserialize_map_in_place(
}
});
- let this = &params.this;
+ let this_type = &params.this_type;
let (_, _, ty_generics, _) = split_with_de_lifetime(params);
let let_default = match cattrs.default() {
attr::Default::Default => Some(quote!(
- let __default: #this #ty_generics = _serde::__private::Default::default();
+ let __default: #this_type #ty_generics = _serde::__private::Default::default();
)),
attr::Default::Path(path) => Some(quote!(
- let __default: #this #ty_generics = #path();
+ let __default: #this_type #ty_generics = #path();
)),
attr::Default::None => {
// We don't need the default value, to prevent an unused variable warning
@@ -2844,7 +2854,7 @@ fn wrap_deserialize_with(
value_ty: &TokenStream,
deserialize_with: &syn::ExprPath,
) -> (TokenStream, TokenStream) {
- let this = &params.this;
+ let this_type = &params.this_type;
let (de_impl_generics, de_ty_generics, ty_generics, where_clause) =
split_with_de_lifetime(params);
let delife = params.borrowed.de_lifetime();
@@ -2852,7 +2862,7 @@ fn wrap_deserialize_with(
let wrapper = quote! {
struct __DeserializeWith #de_impl_generics #where_clause {
value: #value_ty,
- phantom: _serde::__private::PhantomData<#this #ty_generics>,
+ phantom: _serde::__private::PhantomData<#this_type #ty_generics>,
lifetime: _serde::__private::PhantomData<&#delife ()>,
}
@@ -2903,7 +2913,7 @@ fn unwrap_to_variant_closure(
variant: &Variant,
with_wrapper: bool,
) -> TokenStream {
- let this = &params.this;
+ let this_value = &params.this_value;
let variant_ident = &variant.ident;
let (arg, wrapper) = if with_wrapper {
@@ -2924,23 +2934,23 @@ fn unwrap_to_variant_closure(
Style::Struct if variant.fields.len() == 1 => {
let member = &variant.fields[0].member;
quote! {
- |#arg| #this::#variant_ident { #member: #wrapper }
+ |#arg| #this_value::#variant_ident { #member: #wrapper }
}
}
Style::Struct => {
let members = variant.fields.iter().map(|field| &field.member);
quote! {
- |#arg| #this::#variant_ident { #(#members: #wrapper.#field_access),* }
+ |#arg| #this_value::#variant_ident { #(#members: #wrapper.#field_access),* }
}
}
Style::Tuple => quote! {
- |#arg| #this::#variant_ident(#(#wrapper.#field_access),*)
+ |#arg| #this_value::#variant_ident(#(#wrapper.#field_access),*)
},
Style::Newtype => quote! {
- |#arg| #this::#variant_ident(#wrapper)
+ |#arg| #this_value::#variant_ident(#wrapper)
},
Style::Unit => quote! {
- |#arg| #this::#variant_ident
+ |#arg| #this_value::#variant_ident
},
}
}
diff --git a/vendor/serde_derive/src/internals/check.rs b/vendor/serde_derive/src/internals/check.rs
index 0e2484a79..eb1297aa7 100644
--- a/vendor/serde_derive/src/internals/check.rs
+++ b/vendor/serde_derive/src/internals/check.rs
@@ -6,6 +6,7 @@ use syn::{Member, Type};
/// Cross-cutting checks that require looking at more than a single attrs
/// object. Simpler checks should happen when parsing and building the attrs.
pub fn check(cx: &Ctxt, cont: &mut Container, derive: Derive) {
+ check_remote_generic(cx, cont);
check_getter(cx, cont);
check_flatten(cx, cont);
check_identifier(cx, cont);
@@ -16,6 +17,28 @@ pub fn check(cx: &Ctxt, cont: &mut Container, derive: Derive) {
check_from_and_try_from(cx, cont);
}
+/// Remote derive definition type must have either all of the generics of the
+/// remote type:
+///
+/// #[serde(remote = "Generic")]
+/// struct Generic<T> {…}
+///
+/// or none of them, i.e. defining impls for one concrete instantiation of the
+/// remote type only:
+///
+/// #[serde(remote = "Generic<T>")]
+/// struct ConcreteDef {…}
+///
+fn check_remote_generic(cx: &Ctxt, cont: &Container) {
+ if let Some(remote) = cont.attrs.remote() {
+ let local_has_generic = !cont.generics.params.is_empty();
+ let remote_has_generic = !remote.segments.last().unwrap().arguments.is_none();
+ if local_has_generic && remote_has_generic {
+ cx.error_spanned_by(remote, "remove generic parameters from this path");
+ }
+ }
+}
+
/// Getters are only allowed inside structs (not enums) with the `remote`
/// attribute.
fn check_getter(cx: &Ctxt, cont: &Container) {
diff --git a/vendor/serde_derive/src/lib.rs b/vendor/serde_derive/src/lib.rs
index fc8529e40..410078911 100644
--- a/vendor/serde_derive/src/lib.rs
+++ b/vendor/serde_derive/src/lib.rs
@@ -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.147")]
+#![doc(html_root_url = "https://docs.rs/serde_derive/1.0.152")]
#![allow(unknown_lints, bare_trait_objects)]
// Ignored clippy lints
#![allow(
@@ -43,7 +43,6 @@
clippy::enum_glob_use,
clippy::indexing_slicing,
clippy::items_after_statements,
- clippy::let_underscore_drop,
clippy::manual_assert,
clippy::map_err_ignore,
clippy::match_same_arms,
@@ -85,6 +84,7 @@ mod de;
mod dummy;
mod pretend;
mod ser;
+mod this;
mod try;
#[proc_macro_derive(Serialize, attributes(serde))]
diff --git a/vendor/serde_derive/src/ser.rs b/vendor/serde_derive/src/ser.rs
index 529a20d79..43695dd0c 100644
--- a/vendor/serde_derive/src/ser.rs
+++ b/vendor/serde_derive/src/ser.rs
@@ -8,6 +8,7 @@ use fragment::{Fragment, Match, Stmts};
use internals::ast::{Container, Data, Field, Style, Variant};
use internals::{attr, replace_receiver, Ctxt, Derive};
use pretend;
+use this;
pub fn expand_derive_serialize(
input: &mut syn::DeriveInput,
@@ -82,9 +83,13 @@ struct Parameters {
self_var: Ident,
/// Path to the type the impl is for. Either a single `Ident` for local
- /// types or `some::remote::Ident` for remote types. Does not include
- /// generic parameters.
- this: syn::Path,
+ /// types (does not include generic parameters) or `some::remote::Path` for
+ /// remote types.
+ this_type: syn::Path,
+
+ /// Same as `this_type` but using `::<T>` for generic parameters for use in
+ /// expression position.
+ this_value: syn::Path,
/// Generics including any explicit and inferred bounds for the impl.
generics: syn::Generics,
@@ -105,18 +110,15 @@ impl Parameters {
Ident::new("self", Span::call_site())
};
- let this = match cont.attrs.remote() {
- Some(remote) => remote.clone(),
- None => cont.ident.clone().into(),
- };
-
+ let this_type = this::this_type(cont);
+ let this_value = this::this_value(cont);
let is_packed = cont.attrs.is_packed();
-
let generics = build_generics(cont);
Parameters {
self_var,
- this,
+ this_type,
+ this_value,
generics,
is_remote,
is_packed,
@@ -126,7 +128,7 @@ impl Parameters {
/// Type name to use in error messages and `&'static str` arguments to
/// various Serializer methods.
fn type_name(&self) -> String {
- self.this.segments.last().unwrap().ident.to_string()
+ self.this_type.segments.last().unwrap().ident.to_string()
}
}
@@ -427,7 +429,7 @@ fn serialize_variant(
variant_index: u32,
cattrs: &attr::Container,
) -> TokenStream {
- let this = &params.this;
+ let this_value = &params.this_value;
let variant_ident = &variant.ident;
if variant.attrs.skip_serializing() {
@@ -445,32 +447,32 @@ fn serialize_variant(
Style::Struct => quote!({ .. }),
};
quote! {
- #this::#variant_ident #fields_pat => #skipped_err,
+ #this_value::#variant_ident #fields_pat => #skipped_err,
}
} else {
// variant wasn't skipped
let case = match variant.style {
Style::Unit => {
quote! {
- #this::#variant_ident
+ #this_value::#variant_ident
}
}
Style::Newtype => {
quote! {
- #this::#variant_ident(ref __field0)
+ #this_value::#variant_ident(ref __field0)
}
}
Style::Tuple => {
let field_names = (0..variant.fields.len())
.map(|i| Ident::new(&format!("__field{}", i), Span::call_site()));
quote! {
- #this::#variant_ident(#(ref #field_names),*)
+ #this_value::#variant_ident(#(ref #field_names),*)
}
}
Style::Struct => {
let members = variant.fields.iter().map(|f| &f.member);
quote! {
- #this::#variant_ident { #(ref #members),* }
+ #this_value::#variant_ident { #(ref #members),* }
}
}
};
@@ -640,7 +642,7 @@ fn serialize_adjacently_tagged_variant(
tag: &str,
content: &str,
) -> Fragment {
- let this = &params.this;
+ let this_type = &params.this_type;
let type_name = cattrs.name().serialize_name();
let variant_name = variant.attrs.name().serialize_name();
@@ -719,7 +721,7 @@ fn serialize_adjacently_tagged_variant(
quote_block! {
struct __AdjacentlyTagged #wrapper_generics #where_clause {
data: (#(&'__a #fields_ty,)*),
- phantom: _serde::__private::PhantomData<#this #ty_generics>,
+ phantom: _serde::__private::PhantomData<#this_type #ty_generics>,
}
impl #wrapper_impl_generics _serde::Serialize for __AdjacentlyTagged #wrapper_ty_generics #where_clause {
@@ -741,7 +743,7 @@ fn serialize_adjacently_tagged_variant(
try!(_serde::ser::SerializeStruct::serialize_field(
&mut __struct, #content, &__AdjacentlyTagged {
data: (#(#fields_ident,)*),
- phantom: _serde::__private::PhantomData::<#this #ty_generics>,
+ phantom: _serde::__private::PhantomData::<#this_type #ty_generics>,
}));
_serde::ser::SerializeStruct::end(__struct)
}
@@ -866,8 +868,8 @@ enum StructVariant<'a> {
Untagged,
}
-fn serialize_struct_variant<'a>(
- context: StructVariant<'a>,
+fn serialize_struct_variant(
+ context: StructVariant,
params: &Parameters,
fields: &[Field],
name: &str,
@@ -950,8 +952,8 @@ fn serialize_struct_variant<'a>(
}
}
-fn serialize_struct_variant_with_flatten<'a>(
- context: StructVariant<'a>,
+fn serialize_struct_variant_with_flatten(
+ context: StructVariant,
params: &Parameters,
fields: &[Field],
name: &str,
@@ -971,7 +973,7 @@ fn serialize_struct_variant_with_flatten<'a>(
variant_index,
variant_name,
} => {
- let this = &params.this;
+ let this_type = &params.this_type;
let fields_ty = fields.iter().map(|f| &f.ty);
let members = &fields.iter().map(|f| &f.member).collect::<Vec<_>>();
@@ -982,7 +984,7 @@ fn serialize_struct_variant_with_flatten<'a>(
quote_block! {
struct __EnumFlatten #wrapper_generics #where_clause {
data: (#(&'__a #fields_ty,)*),
- phantom: _serde::__private::PhantomData<#this #ty_generics>,
+ phantom: _serde::__private::PhantomData<#this_type #ty_generics>,
}
impl #wrapper_impl_generics _serde::Serialize for __EnumFlatten #wrapper_ty_generics #where_clause {
@@ -1006,7 +1008,7 @@ fn serialize_struct_variant_with_flatten<'a>(
#variant_name,
&__EnumFlatten {
data: (#(#members,)*),
- phantom: _serde::__private::PhantomData::<#this #ty_generics>,
+ phantom: _serde::__private::PhantomData::<#this_type #ty_generics>,
})
}
}
@@ -1192,7 +1194,7 @@ fn wrap_serialize_with(
field_tys: &[&syn::Type],
field_exprs: &[TokenStream],
) -> TokenStream {
- let this = &params.this;
+ let this_type = &params.this_type;
let (_, ty_generics, where_clause) = params.generics.split_for_impl();
let wrapper_generics = if field_exprs.is_empty() {
@@ -1212,7 +1214,7 @@ fn wrap_serialize_with(
quote!({
struct __SerializeWith #wrapper_impl_generics #where_clause {
values: (#(&'__a #field_tys, )*),
- phantom: _serde::__private::PhantomData<#this #ty_generics>,
+ phantom: _serde::__private::PhantomData<#this_type #ty_generics>,
}
impl #wrapper_impl_generics _serde::Serialize for __SerializeWith #wrapper_ty_generics #where_clause {
@@ -1226,7 +1228,7 @@ fn wrap_serialize_with(
&__SerializeWith {
values: (#(#field_exprs, )*),
- phantom: _serde::__private::PhantomData::<#this #ty_generics>,
+ phantom: _serde::__private::PhantomData::<#this_type #ty_generics>,
}
})
}
diff --git a/vendor/serde_derive/src/this.rs b/vendor/serde_derive/src/this.rs
new file mode 100644
index 000000000..32731d089
--- /dev/null
+++ b/vendor/serde_derive/src/this.rs
@@ -0,0 +1,32 @@
+use internals::ast::Container;
+use syn::{Path, PathArguments, Token};
+
+pub fn this_type(cont: &Container) -> Path {
+ if let Some(remote) = cont.attrs.remote() {
+ let mut this = remote.clone();
+ for segment in &mut this.segments {
+ if let PathArguments::AngleBracketed(arguments) = &mut segment.arguments {
+ arguments.colon2_token = None;
+ }
+ }
+ this
+ } else {
+ Path::from(cont.ident.clone())
+ }
+}
+
+pub fn this_value(cont: &Container) -> Path {
+ if let Some(remote) = cont.attrs.remote() {
+ let mut this = remote.clone();
+ for segment in &mut this.segments {
+ if let PathArguments::AngleBracketed(arguments) = &mut segment.arguments {
+ if arguments.colon2_token.is_none() {
+ arguments.colon2_token = Some(Token![::](arguments.lt_token.span));
+ }
+ }
+ }
+ this
+ } else {
+ Path::from(cont.ident.clone())
+ }
+}