Skip to content

Commit

Permalink
Format with rustfmt 0.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed May 23, 2018
1 parent ad62a68 commit 06dcbbb
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 13 deletions.
9 changes: 7 additions & 2 deletions serde_derive/src/bound.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,10 @@ pub fn with_bound(
fn visit_macro(&mut self, _mac: &'ast syn::Macro) {}
}

let all_type_params = generics.type_params().map(|param| param.ident.clone()).collect();
let all_type_params = generics
.type_params()
.map(|param| param.ident.clone())
.collect();

let mut visitor = FindTyParams {
all_type_params: all_type_params,
Expand Down Expand Up @@ -260,7 +263,9 @@ pub fn with_lifetime_bound(generics: &syn::Generics, lifetime: &str) -> syn::Gen
param.bounds.push(bound.clone());
}
syn::GenericParam::Type(ref mut param) => {
param.bounds.push(syn::TypeParamBound::Lifetime(bound.clone()));
param
.bounds
.push(syn::TypeParamBound::Lifetime(bound.clone()));
}
syn::GenericParam::Const(_) => {}
}
Expand Down
19 changes: 14 additions & 5 deletions serde_derive/src/de.rs
Original file line number Diff line number Diff line change
Expand Up @@ -789,7 +789,11 @@ fn deserialize_seq_in_place(
}
}

fn deserialize_newtype_struct(type_path: &TokenStream, params: &Parameters, field: &Field) -> TokenStream {
fn deserialize_newtype_struct(
type_path: &TokenStream,
params: &Parameters,
field: &Field,
) -> TokenStream {
let delife = params.borrowed.de_lifetime();
let field_ty = field.ty;

Expand Down Expand Up @@ -1927,7 +1931,12 @@ fn deserialize_custom_identifier(

let names_idents: Vec<_> = ordinary
.iter()
.map(|variant| (variant.attrs.name().deserialize_name(), variant.ident.clone()))
.map(|variant| {
(
variant.attrs.name().deserialize_name(),
variant.ident.clone(),
)
})
.collect();

let names = names_idents.iter().map(|&(ref name, _)| name);
Expand Down Expand Up @@ -2828,9 +2837,9 @@ impl<'a> ToTokens for InPlaceImplGenerics<'a> {
param.bounds.push(place_lifetime.lifetime.clone());
}
syn::GenericParam::Type(ref mut param) => {
param
.bounds
.push(syn::TypeParamBound::Lifetime(place_lifetime.lifetime.clone()));
param.bounds.push(syn::TypeParamBound::Lifetime(
place_lifetime.lifetime.clone(),
));
}
syn::GenericParam::Const(_) => {}
}
Expand Down
2 changes: 1 addition & 1 deletion serde_derive/src/fragment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

use proc_macro2::TokenStream;
use quote::ToTokens;
use syn::token;
use proc_macro2::TokenStream;

pub enum Fragment {
/// Tokens that can be used as an expression.
Expand Down
4 changes: 1 addition & 3 deletions serde_derive/src/internals/attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -948,9 +948,7 @@ impl Field {

// Parse `#[serde(borrow = "'a + 'b")]`
Meta(NameValue(ref m)) if m.ident == "borrow" => {
if let Ok(lifetimes) =
parse_lit_into_lifetimes(cx, &m.ident, &m.lit)
{
if let Ok(lifetimes) = parse_lit_into_lifetimes(cx, &m.ident, &m.lit) {
if let Ok(borrowable) = borrowable_lifetimes(cx, &ident, &field.ty) {
for lifetime in &lifetimes {
if !borrowable.contains(lifetime) {
Expand Down
6 changes: 4 additions & 2 deletions serde_derive/src/internals/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,9 @@ fn check_transparent(cx: &Ctxt, cont: &mut Container, derive: Derive) {
for field in fields {
if allow_transparent(field, derive) {
if transparent_field.is_some() {
cx.error("#[serde(transparent)] requires struct to have at most one transparent field");
cx.error(
"#[serde(transparent)] requires struct to have at most one transparent field",
);
return;
}
transparent_field = Some(field);
Expand All @@ -326,7 +328,7 @@ fn check_transparent(cx: &Ctxt, cont: &mut Container, derive: Derive) {
Derive::Deserialize => {
cx.error("#[serde(transparent)] requires at least one field that is neither skipped nor has a default");
}
}
},
}
}

Expand Down

0 comments on commit 06dcbbb

Please sign in to comment.