mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-04-23 03:38:00 +00:00
Format with rustfmt 2019-03-27
This commit is contained in:
@@ -61,7 +61,12 @@ pub fn expand_derive_deserialize(input: &syn::DeriveInput) -> Result<TokenStream
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(dummy::wrap_in_const(cont.attrs.custom_serde_path(), "DESERIALIZE", ident, impl_block))
|
Ok(dummy::wrap_in_const(
|
||||||
|
cont.attrs.custom_serde_path(),
|
||||||
|
"DESERIALIZE",
|
||||||
|
ident,
|
||||||
|
impl_block,
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn precondition(cx: &Ctxt, cont: &Container) {
|
fn precondition(cx: &Ctxt, cont: &Container) {
|
||||||
|
|||||||
@@ -3,7 +3,12 @@ use proc_macro2::{Ident, Span, TokenStream};
|
|||||||
use syn;
|
use syn;
|
||||||
use try;
|
use try;
|
||||||
|
|
||||||
pub fn wrap_in_const(serde_path: Option<&syn::Path>, trait_: &str, ty: &Ident, code: TokenStream) -> TokenStream {
|
pub fn wrap_in_const(
|
||||||
|
serde_path: Option<&syn::Path>,
|
||||||
|
trait_: &str,
|
||||||
|
ty: &Ident,
|
||||||
|
code: TokenStream,
|
||||||
|
) -> TokenStream {
|
||||||
let try_replacement = try::replacement();
|
let try_replacement = try::replacement();
|
||||||
|
|
||||||
let dummy_const = Ident::new(
|
let dummy_const = Ident::new(
|
||||||
@@ -11,9 +16,13 @@ pub fn wrap_in_const(serde_path: Option<&syn::Path>, trait_: &str, ty: &Ident, c
|
|||||||
Span::call_site(),
|
Span::call_site(),
|
||||||
);
|
);
|
||||||
|
|
||||||
let use_serde = serde_path.map(|path| {
|
let use_serde = serde_path
|
||||||
quote!(use #path as _serde;)
|
.map(|path| {
|
||||||
}).unwrap_or_else(|| {
|
quote! {
|
||||||
|
use #path as _serde;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.unwrap_or_else(|| {
|
||||||
quote! {
|
quote! {
|
||||||
#[allow(unknown_lints)]
|
#[allow(unknown_lints)]
|
||||||
#[cfg_attr(feature = "cargo-clippy", allow(useless_attribute))]
|
#[cfg_attr(feature = "cargo-clippy", allow(useless_attribute))]
|
||||||
|
|||||||
@@ -52,7 +52,12 @@ pub fn expand_derive_serialize(input: &syn::DeriveInput) -> Result<TokenStream,
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(dummy::wrap_in_const(cont.attrs.custom_serde_path(), "SERIALIZE", ident, impl_block))
|
Ok(dummy::wrap_in_const(
|
||||||
|
cont.attrs.custom_serde_path(),
|
||||||
|
"SERIALIZE",
|
||||||
|
ident,
|
||||||
|
impl_block,
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn precondition(cx: &Ctxt, cont: &Container) {
|
fn precondition(cx: &Ctxt, cont: &Container) {
|
||||||
|
|||||||
@@ -19,7 +19,8 @@ mod fake_serde {
|
|||||||
where
|
where
|
||||||
T: Serialize,
|
T: Serialize,
|
||||||
T: for<'a> Deserialize<'a>,
|
T: for<'a> Deserialize<'a>,
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
pub trait Serialize {
|
pub trait Serialize {
|
||||||
fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error>;
|
fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error>;
|
||||||
|
|||||||
Reference in New Issue
Block a user