Format with rustfmt 1.0.0-nightly
This commit is contained in:
parent
a8a54c0568
commit
9afc5fef11
@ -874,7 +874,9 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
let visitor = VecVisitor { marker: PhantomData };
|
||||
let visitor = VecVisitor {
|
||||
marker: PhantomData,
|
||||
};
|
||||
deserializer.deserialize_seq(visitor)
|
||||
}
|
||||
|
||||
@ -1760,11 +1762,7 @@ where
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#[cfg(all(
|
||||
de_rc_dst,
|
||||
feature = "rc",
|
||||
any(feature = "std", feature = "alloc")
|
||||
))]
|
||||
#[cfg(all(de_rc_dst, feature = "rc", any(feature = "std", feature = "alloc")))]
|
||||
macro_rules! box_forwarded_impl {
|
||||
(
|
||||
$(#[doc = $doc:tt])*
|
||||
@ -1785,11 +1783,7 @@ macro_rules! box_forwarded_impl {
|
||||
};
|
||||
}
|
||||
|
||||
#[cfg(all(
|
||||
de_rc_dst,
|
||||
feature = "rc",
|
||||
any(feature = "std", feature = "alloc")
|
||||
))]
|
||||
#[cfg(all(de_rc_dst, feature = "rc", any(feature = "std", feature = "alloc")))]
|
||||
box_forwarded_impl! {
|
||||
/// This impl requires the [`"rc"`] Cargo feature of Serde.
|
||||
///
|
||||
@ -1801,11 +1795,7 @@ box_forwarded_impl! {
|
||||
Rc
|
||||
}
|
||||
|
||||
#[cfg(all(
|
||||
de_rc_dst,
|
||||
feature = "rc",
|
||||
any(feature = "std", feature = "alloc")
|
||||
))]
|
||||
#[cfg(all(de_rc_dst, feature = "rc", any(feature = "std", feature = "alloc")))]
|
||||
box_forwarded_impl! {
|
||||
/// This impl requires the [`"rc"`] Cargo feature of Serde.
|
||||
///
|
||||
|
@ -409,10 +409,9 @@ mod content {
|
||||
}
|
||||
|
||||
fn end(mut self) -> Result<M::Ok, M::Error> {
|
||||
try!(
|
||||
self.map
|
||||
.serialize_value(&Content::TupleStruct(self.name, self.fields))
|
||||
);
|
||||
try!(self
|
||||
.map
|
||||
.serialize_value(&Content::TupleStruct(self.name, self.fields)));
|
||||
self.map.end()
|
||||
}
|
||||
}
|
||||
@ -454,10 +453,9 @@ mod content {
|
||||
}
|
||||
|
||||
fn end(mut self) -> Result<M::Ok, M::Error> {
|
||||
try!(
|
||||
self.map
|
||||
.serialize_value(&Content::Struct(self.name, self.fields))
|
||||
);
|
||||
try!(self
|
||||
.map
|
||||
.serialize_value(&Content::Struct(self.name, self.fields)));
|
||||
self.map.end()
|
||||
}
|
||||
}
|
||||
@ -1328,10 +1326,9 @@ where
|
||||
}
|
||||
|
||||
fn end(self) -> Result<(), Self::Error> {
|
||||
try!(
|
||||
self.map
|
||||
.serialize_value(&Content::Struct(self.name, self.fields))
|
||||
);
|
||||
try!(self
|
||||
.map
|
||||
.serialize_value(&Content::Struct(self.name, self.fields)));
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
@ -32,7 +32,8 @@ pub fn without_defaults(generics: &syn::Generics) -> syn::Generics {
|
||||
..param.clone()
|
||||
}),
|
||||
_ => param.clone(),
|
||||
}).collect(),
|
||||
})
|
||||
.collect(),
|
||||
..generics.clone()
|
||||
}
|
||||
}
|
||||
@ -168,7 +169,8 @@ pub fn with_bound(
|
||||
associated_type_usage: Vec::new(),
|
||||
};
|
||||
match cont.data {
|
||||
Data::Enum(ref variants) => for variant in variants.iter() {
|
||||
Data::Enum(ref variants) => {
|
||||
for variant in variants.iter() {
|
||||
let relevant_fields = variant
|
||||
.fields
|
||||
.iter()
|
||||
@ -176,7 +178,8 @@ pub fn with_bound(
|
||||
for field in relevant_fields {
|
||||
visitor.visit_field(field.original);
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
Data::Struct(_, ref fields) => {
|
||||
for field in fields.iter().filter(|field| filter(&field.attrs, None)) {
|
||||
visitor.visit_field(field.original);
|
||||
@ -193,7 +196,8 @@ pub fn with_bound(
|
||||
.map(|id| syn::TypePath {
|
||||
qself: None,
|
||||
path: id.into(),
|
||||
}).chain(associated_type_usage.into_iter().cloned())
|
||||
})
|
||||
.chain(associated_type_usage.into_iter().cloned())
|
||||
.map(|bounded_ty| {
|
||||
syn::WherePredicate::Type(syn::PredicateType {
|
||||
lifetimes: None,
|
||||
@ -206,7 +210,8 @@ pub fn with_bound(
|
||||
modifier: syn::TraitBoundModifier::None,
|
||||
lifetimes: None,
|
||||
path: bound.clone(),
|
||||
})].into_iter()
|
||||
})]
|
||||
.into_iter()
|
||||
.collect(),
|
||||
})
|
||||
});
|
||||
@ -239,7 +244,8 @@ pub fn with_self_bound(
|
||||
modifier: syn::TraitBoundModifier::None,
|
||||
lifetimes: None,
|
||||
path: bound.clone(),
|
||||
})].into_iter()
|
||||
})]
|
||||
.into_iter()
|
||||
.collect(),
|
||||
}));
|
||||
generics
|
||||
@ -269,7 +275,8 @@ pub fn with_lifetime_bound(generics: &syn::Generics, lifetime: &str) -> syn::Gen
|
||||
syn::GenericParam::Const(_) => {}
|
||||
}
|
||||
param
|
||||
})).collect();
|
||||
}))
|
||||
.collect();
|
||||
|
||||
syn::Generics {
|
||||
params: params,
|
||||
@ -305,11 +312,13 @@ fn type_of_item(cont: &Container) -> syn::Type {
|
||||
syn::GenericParam::Const(_) => {
|
||||
panic!("Serde does not support const generics yet");
|
||||
}
|
||||
}).collect(),
|
||||
})
|
||||
.collect(),
|
||||
gt_token: <Token![>]>::default(),
|
||||
},
|
||||
),
|
||||
}].into_iter()
|
||||
}]
|
||||
.into_iter()
|
||||
.collect(),
|
||||
},
|
||||
})
|
||||
|
@ -1369,7 +1369,8 @@ fn deserialize_adjacently_tagged_enum(
|
||||
quote! {
|
||||
__Field::#variant_index => #block
|
||||
}
|
||||
}).collect();
|
||||
})
|
||||
.collect();
|
||||
|
||||
let expecting = format!("adjacently tagged enum {}", params.type_name());
|
||||
let type_name = cattrs.name().deserialize_name();
|
||||
@ -1962,7 +1963,8 @@ fn deserialize_custom_identifier(
|
||||
variant.attrs.name().deserialize_name(),
|
||||
variant.ident.clone(),
|
||||
)
|
||||
}).collect();
|
||||
})
|
||||
.collect();
|
||||
|
||||
let names = names_idents.iter().map(|&(ref name, _)| name);
|
||||
|
||||
|
@ -83,7 +83,8 @@ impl<'a> Container<'a> {
|
||||
|
||||
let mut has_flatten = false;
|
||||
match data {
|
||||
Data::Enum(ref mut variants) => for variant in variants {
|
||||
Data::Enum(ref mut variants) => {
|
||||
for variant in variants {
|
||||
variant.attrs.rename_by_rule(attrs.rename_all());
|
||||
for field in &mut variant.fields {
|
||||
if field.attrs.flatten() {
|
||||
@ -91,13 +92,16 @@ impl<'a> Container<'a> {
|
||||
}
|
||||
field.attrs.rename_by_rule(variant.attrs.rename_all());
|
||||
}
|
||||
},
|
||||
Data::Struct(_, ref mut fields) => for field in fields {
|
||||
}
|
||||
}
|
||||
Data::Struct(_, ref mut fields) => {
|
||||
for field in fields {
|
||||
if field.attrs.flatten() {
|
||||
has_flatten = true;
|
||||
}
|
||||
field.attrs.rename_by_rule(attrs.rename_all());
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if has_flatten {
|
||||
@ -147,7 +151,8 @@ fn enum_from_ast<'a>(
|
||||
style: style,
|
||||
fields: fields,
|
||||
}
|
||||
}).collect()
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
fn struct_from_ast<'a>(
|
||||
@ -190,5 +195,6 @@ fn fields_from_ast<'a>(
|
||||
attrs: attr::Field::from_ast(cx, i, field, attrs, container_default),
|
||||
ty: &field.ty,
|
||||
original: field,
|
||||
}).collect()
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
@ -1372,7 +1372,9 @@ fn is_cow(ty: &syn::Type, elem: fn(&syn::Type) -> bool) -> bool {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
seg.ident == "Cow" && args.len() == 2 && match (&args[0], &args[1]) {
|
||||
seg.ident == "Cow"
|
||||
&& args.len() == 2
|
||||
&& match (&args[0], &args[1]) {
|
||||
(&syn::GenericArgument::Lifetime(_), &syn::GenericArgument::Type(ref arg)) => elem(arg),
|
||||
_ => false,
|
||||
}
|
||||
@ -1397,7 +1399,9 @@ fn is_option(ty: &syn::Type, elem: fn(&syn::Type) -> bool) -> bool {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
seg.ident == "Option" && args.len() == 1 && match args[0] {
|
||||
seg.ident == "Option"
|
||||
&& args.len() == 1
|
||||
&& match args[0] {
|
||||
syn::GenericArgument::Type(ref arg) => elem(arg),
|
||||
_ => false,
|
||||
}
|
||||
@ -1492,9 +1496,11 @@ fn collect_lifetimes(ty: &syn::Type, out: &mut BTreeSet<syn::Lifetime>) {
|
||||
out.extend(ty.lifetime.iter().cloned());
|
||||
collect_lifetimes(&ty.elem, out);
|
||||
}
|
||||
syn::Type::Tuple(ref ty) => for elem in &ty.elems {
|
||||
syn::Type::Tuple(ref ty) => {
|
||||
for elem in &ty.elems {
|
||||
collect_lifetimes(elem, out);
|
||||
},
|
||||
}
|
||||
}
|
||||
syn::Type::Path(ref ty) => {
|
||||
if let Some(ref qself) = ty.qself {
|
||||
collect_lifetimes(&qself.ty, out);
|
||||
|
@ -62,7 +62,8 @@ fn pretend_fields_used(cont: &Container) -> TokenStream {
|
||||
Some(quote!(#type_ident::#variant_ident #pat))
|
||||
}
|
||||
_ => None,
|
||||
}).collect::<Vec<_>>(),
|
||||
})
|
||||
.collect::<Vec<_>>(),
|
||||
Data::Struct(Style::Struct, ref fields) => {
|
||||
let pat = struct_pattern(fields);
|
||||
vec![quote!(#type_ident #pat)]
|
||||
|
@ -288,7 +288,8 @@ fn serialize_tuple_struct(
|
||||
let field_expr = get_member(params, field, &Member::Unnamed(index));
|
||||
quote!(if #path(#field_expr) { 0 } else { 1 })
|
||||
}
|
||||
}).fold(quote!(0), |sum, expr| quote!(#sum + #expr));
|
||||
})
|
||||
.fold(quote!(0), |sum, expr| quote!(#sum + #expr));
|
||||
|
||||
quote_block! {
|
||||
let #let_mut __serde_state = try!(_serde::Serializer::serialize_tuple_struct(__serializer, #type_name, #len));
|
||||
@ -331,7 +332,8 @@ fn serialize_struct_as_struct(
|
||||
let field_expr = get_member(params, field, &field.member);
|
||||
quote!(if #path(#field_expr) { 0 } else { 1 })
|
||||
}
|
||||
}).fold(quote!(0), |sum, expr| quote!(#sum + #expr));
|
||||
})
|
||||
.fold(quote!(0), |sum, expr| quote!(#sum + #expr));
|
||||
|
||||
quote_block! {
|
||||
let #let_mut __serde_state = try!(_serde::Serializer::serialize_struct(__serializer, #type_name, #len));
|
||||
@ -365,7 +367,8 @@ fn serialize_struct_as_map(
|
||||
let field_expr = get_member(params, field, &field.member);
|
||||
quote!(if #path(#field_expr) { 0 } else { 1 })
|
||||
}
|
||||
}).fold(quote!(0), |sum, expr| quote!(#sum + #expr));
|
||||
})
|
||||
.fold(quote!(0), |sum, expr| quote!(#sum + #expr));
|
||||
quote!(_serde::export::Some(#len))
|
||||
};
|
||||
|
||||
@ -386,7 +389,8 @@ fn serialize_enum(params: &Parameters, variants: &[Variant], cattrs: &attr::Cont
|
||||
.enumerate()
|
||||
.map(|(variant_index, variant)| {
|
||||
serialize_variant(params, variant, variant_index as u32, cattrs)
|
||||
}).collect();
|
||||
})
|
||||
.collect();
|
||||
|
||||
quote_expr! {
|
||||
match *#self_var {
|
||||
@ -790,7 +794,8 @@ fn serialize_tuple_variant(
|
||||
let field_expr = Ident::new(&format!("__field{}", i), Span::call_site());
|
||||
quote!(if #path(#field_expr) { 0 } else { 1 })
|
||||
}
|
||||
}).fold(quote!(0), |sum, expr| quote!(#sum + #expr));
|
||||
})
|
||||
.fold(quote!(0), |sum, expr| quote!(#sum + #expr));
|
||||
|
||||
match context {
|
||||
TupleVariant::ExternallyTagged {
|
||||
@ -867,7 +872,8 @@ fn serialize_struct_variant<'a>(
|
||||
Some(path) => quote!(if #path(#member) { 0 } else { 1 }),
|
||||
None => quote!(1),
|
||||
}
|
||||
}).fold(quote!(0), |sum, expr| quote!(#sum + #expr));
|
||||
})
|
||||
.fold(quote!(0), |sum, expr| quote!(#sum + #expr));
|
||||
|
||||
match context {
|
||||
StructVariant::ExternallyTagged {
|
||||
@ -1046,7 +1052,8 @@ fn serialize_tuple_struct_visitor(
|
||||
None => ser,
|
||||
Some(skip) => quote!(if !#skip { #ser }),
|
||||
}
|
||||
}).collect()
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
fn serialize_struct_visitor(
|
||||
@ -1140,7 +1147,8 @@ fn wrap_serialize_variant_with(
|
||||
}
|
||||
};
|
||||
quote!(#id)
|
||||
}).collect();
|
||||
})
|
||||
.collect();
|
||||
wrap_serialize_with(
|
||||
params,
|
||||
serialize_with,
|
||||
|
@ -351,10 +351,7 @@ struct ContainsNotDeserialize<A, B, C: DeserializeWith, E: MyDefault> {
|
||||
a: A,
|
||||
#[serde(skip_deserializing, default)]
|
||||
b: B,
|
||||
#[serde(
|
||||
deserialize_with = "DeserializeWith::deserialize_with",
|
||||
default
|
||||
)]
|
||||
#[serde(deserialize_with = "DeserializeWith::deserialize_with", default)]
|
||||
c: C,
|
||||
#[serde(skip_deserializing, default = "MyDefault::my_default")]
|
||||
e: E,
|
||||
|
@ -7,10 +7,7 @@
|
||||
// except according to those terms.
|
||||
|
||||
#![cfg_attr(feature = "cargo-clippy", allow(renamed_and_removed_lints))]
|
||||
#![cfg_attr(
|
||||
feature = "cargo-clippy",
|
||||
allow(decimal_literal_representation)
|
||||
)]
|
||||
#![cfg_attr(feature = "cargo-clippy", allow(decimal_literal_representation))]
|
||||
#![cfg_attr(feature = "unstable", feature(never_type))]
|
||||
|
||||
#[macro_use]
|
||||
@ -229,7 +226,8 @@ fn assert_de_tokens_ignore(ignorable_tokens: &[Token]) {
|
||||
Token::Str("a"),
|
||||
Token::I32(1),
|
||||
Token::Str("ignored"),
|
||||
].into_iter()
|
||||
]
|
||||
.into_iter()
|
||||
.chain(ignorable_tokens.to_vec().into_iter())
|
||||
.chain(vec![Token::MapEnd].into_iter())
|
||||
.collect();
|
||||
|
@ -198,10 +198,7 @@ fn test_gen() {
|
||||
assert::<WithTraits1<X, X>>();
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
#[serde(bound(
|
||||
serialize = "D: SerializeWith",
|
||||
deserialize = "D: DeserializeWith"
|
||||
))]
|
||||
#[serde(bound(serialize = "D: SerializeWith", deserialize = "D: DeserializeWith"))]
|
||||
struct WithTraits2<D, E> {
|
||||
#[serde(
|
||||
serialize_with = "SerializeWith::serialize_with",
|
||||
@ -238,10 +235,7 @@ fn test_gen() {
|
||||
assert::<VariantWithTraits1<X, X>>();
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
#[serde(bound(
|
||||
serialize = "D: SerializeWith",
|
||||
deserialize = "D: DeserializeWith"
|
||||
))]
|
||||
#[serde(bound(serialize = "D: SerializeWith", deserialize = "D: DeserializeWith"))]
|
||||
enum VariantWithTraits2<D, E> {
|
||||
#[serde(
|
||||
serialize_with = "SerializeWith::serialize_with",
|
||||
|
Loading…
x
Reference in New Issue
Block a user