Format with rustfmt 0.6.1

This commit is contained in:
David Tolnay 2018-05-05 00:18:21 -07:00
parent 8c3b52e308
commit 0e1d065402
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82

View File

@ -54,8 +54,8 @@ fn pretend_fields_used(cont: &Container) -> Tokens {
let (_, ty_generics, _) = cont.generics.split_for_impl(); let (_, ty_generics, _) = cont.generics.split_for_impl();
let patterns = match cont.data { let patterns = match cont.data {
Data::Enum(ref variants) => { Data::Enum(ref variants) => variants
variants.iter() .iter()
.filter_map(|variant| match variant.style { .filter_map(|variant| match variant.style {
Style::Struct => { Style::Struct => {
let variant_ident = variant.ident; let variant_ident = variant.ident;
@ -64,8 +64,7 @@ fn pretend_fields_used(cont: &Container) -> Tokens {
} }
_ => None, _ => None,
}) })
.collect::<Vec<_>>() .collect::<Vec<_>>(),
}
Data::Struct(Style::Struct, ref fields) => { Data::Struct(Style::Struct, ref fields) => {
let pat = struct_pattern(fields); let pat = struct_pattern(fields);
vec![quote!(#type_ident #pat)] vec![quote!(#type_ident #pat)]
@ -106,8 +105,7 @@ fn pretend_variants_used(cont: &Container) -> Tokens {
let (_, ty_generics, _) = cont.generics.split_for_impl(); let (_, ty_generics, _) = cont.generics.split_for_impl();
let turbofish = ty_generics.as_turbofish(); let turbofish = ty_generics.as_turbofish();
let cases = variants.iter() let cases = variants.iter().map(|variant| {
.map(|variant| {
let variant_ident = variant.ident; let variant_ident = variant.ident;
let ref placeholders = (0..variant.fields.len()) let ref placeholders = (0..variant.fields.len())
.map(|i| Ident::new(&format!("__v{}", i), Span::call_site())) .map(|i| Ident::new(&format!("__v{}", i), Span::call_site()))
@ -118,9 +116,7 @@ fn pretend_variants_used(cont: &Container) -> Tokens {
let names = variant.fields.iter().map(|field| field.ident); let names = variant.fields.iter().map(|field| field.ident);
quote!({ #(#names: #placeholders),* }) quote!({ #(#names: #placeholders),* })
} }
Style::Tuple | Style::Newtype => { Style::Tuple | Style::Newtype => quote!(( #(#placeholders),* )),
quote!(( #(#placeholders),* ))
}
Style::Unit => quote!(), Style::Unit => quote!(),
}; };
@ -139,7 +135,7 @@ fn pretend_variants_used(cont: &Container) -> Tokens {
fn struct_pattern(fields: &[Field]) -> Tokens { fn struct_pattern(fields: &[Field]) -> Tokens {
let names = fields.iter().map(|field| field.ident); let names = fields.iter().map(|field| field.ident);
let placeholders = (0..fields.len()) let placeholders =
.map(|i| Ident::new(&format!("__v{}", i), Span::call_site())); (0..fields.len()).map(|i| Ident::new(&format!("__v{}", i), Span::call_site()));
quote!({ #(#names: ref #placeholders),* }) quote!({ #(#names: ref #placeholders),* })
} }