From afd92cd7fec1428944617434c1c1862c4d05c182 Mon Sep 17 00:00:00 2001
From: nWacky <gosha.evtushenko@gmail.com>
Date: Mon, 4 Nov 2019 16:55:36 +0300
Subject: [PATCH] Format

---
 examples/warp_async/src/main.rs               |  27 ++--
 .../juniper_tests/src/codegen/unions.rs       |   3 -
 juniper/src/lib.rs                            |   7 +-
 juniper/src/macros/tests/args.rs              | 136 +++++++++---------
 juniper/src/macros/tests/union.rs             |  20 ++-
 juniper/src/schema/schema.rs                  |  11 +-
 juniper/src/tests/introspection_tests.rs      |   2 +-
 juniper/src/types/async_await.rs              |  16 ++-
 juniper/src/types/pointers.rs                 |  16 +--
 juniper_codegen/src/impl_object.rs            |  13 +-
 juniper_codegen/src/impl_union.rs             |  31 ++--
 juniper_codegen/src/lib.rs                    |   1 -
 12 files changed, 139 insertions(+), 144 deletions(-)

diff --git a/examples/warp_async/src/main.rs b/examples/warp_async/src/main.rs
index a7142d4e..51c85690 100644
--- a/examples/warp_async/src/main.rs
+++ b/examples/warp_async/src/main.rs
@@ -2,13 +2,11 @@
 //! This example demonstrates async/await usage with warp.
 //! NOTE: this uses tokio 0.1 , not the alpha tokio 0.2.
 
-use juniper::{EmptyMutation, RootNode, FieldError};
+use juniper::{EmptyMutation, FieldError, RootNode};
 use warp::{http::Response, Filter};
 
 #[derive(Clone)]
-struct Context {
-
-}
+struct Context {}
 impl juniper::Context for Context {}
 
 #[derive(juniper::GraphQLEnum, Clone, Copy)]
@@ -43,23 +41,24 @@ impl User {
     }
 }
 
-struct Query; 
+struct Query;
 
 #[juniper::object(Context = Context)]
 impl Query {
     async fn users() -> Vec<User> {
-        vec![
-            User{
-                id: 1,
-                kind: UserKind::Admin,
-                name: "user1".into(),
-            },
-        ]
+        vec![User {
+            id: 1,
+            kind: UserKind::Admin,
+            name: "user1".into(),
+        }]
     }
 
     /// Fetch a URL and return the response body text.
     async fn request(url: String) -> Result<String, FieldError> {
-        use futures::{ compat::{Stream01CompatExt, Future01CompatExt}, stream::TryStreamExt};
+        use futures::{
+            compat::{Future01CompatExt, Stream01CompatExt},
+            stream::TryStreamExt,
+        };
 
         let res = reqwest::r#async::Client::new()
             .get(&url)
@@ -95,7 +94,7 @@ fn main() {
 
     log::info!("Listening on 127.0.0.1:8080");
 
-    let state = warp::any().map(move || Context{} );
+    let state = warp::any().map(move || Context {});
     let graphql_filter = juniper_warp::make_graphql_filter_async(schema(), state.boxed());
 
     warp::serve(
diff --git a/integration_tests/juniper_tests/src/codegen/unions.rs b/integration_tests/juniper_tests/src/codegen/unions.rs
index fd40910d..8b137891 100644
--- a/integration_tests/juniper_tests/src/codegen/unions.rs
+++ b/integration_tests/juniper_tests/src/codegen/unions.rs
@@ -1,4 +1 @@
 
-
-
-
diff --git a/juniper/src/lib.rs b/juniper/src/lib.rs
index 462c6641..18bba937 100644
--- a/juniper/src/lib.rs
+++ b/juniper/src/lib.rs
@@ -110,15 +110,14 @@ extern crate uuid;
 // This allows users to just depend on juniper and get the derive
 // functionality automatically.
 pub use juniper_codegen::{
-    object, GraphQLEnum, GraphQLInputObject, GraphQLObject, GraphQLScalarValue, ScalarValue,
-    union,
+    object, union, GraphQLEnum, GraphQLInputObject, GraphQLObject, GraphQLScalarValue, ScalarValue,
 };
 // Internal macros are not exported,
 // but declared at the root to make them easier to use.
 #[allow(unused_imports)]
 use juniper_codegen::{
-    object_internal, GraphQLEnumInternal, GraphQLInputObjectInternal, GraphQLScalarValueInternal,
-    union_internal,
+    object_internal, union_internal, GraphQLEnumInternal, GraphQLInputObjectInternal,
+    GraphQLScalarValueInternal,
 };
 
 #[macro_use]
diff --git a/juniper/src/macros/tests/args.rs b/juniper/src/macros/tests/args.rs
index 3f60a076..2db10376 100644
--- a/juniper/src/macros/tests/args.rs
+++ b/juniper/src/macros/tests/args.rs
@@ -73,12 +73,12 @@ impl Root {
         0
     }
 
-     fn attr_arg_descr(#[doc = "The arg"] arg: i32) -> i32 { 0 }
-     fn attr_arg_descr_collapse(
-         #[doc = "The arg"]
-         #[doc = "and more details"]
-         arg: i32,
-     ) -> i32 { 0 }
+    fn attr_arg_descr(arg: i32) -> i32 {
+        0
+    }
+    fn attr_arg_descr_collapse(arg: i32) -> i32 {
+        0
+    }
 
     #[graphql(arguments(arg(default = 123,),))]
     fn arg_with_default(arg: i32) -> i32 {
@@ -558,71 +558,71 @@ fn introspect_field_multi_args_descr_trailing_comma() {
     });
 }
 
- #[test]
- fn introspect_field_attr_arg_descr() {
-     run_args_info_query("attrArgDescr", |args| {
-         assert_eq!(args.len(), 1);
+#[test]
+fn introspect_field_attr_arg_descr() {
+    run_args_info_query("attrArgDescr", |args| {
+        assert_eq!(args.len(), 1);
 
-         assert!(args.contains(&Value::object(
-             vec![
-                 ("name", Value::scalar("arg")),
-                 ("description", Value::scalar("The arg")),
-                 ("defaultValue", Value::null()),
-                 (
-                     "type",
-                     Value::object(
-                         vec![
-                             ("name", Value::null()),
-                             (
-                                 "ofType",
-                                 Value::object(
-                                     vec![("name", Value::scalar("Int"))].into_iter().collect(),
-                                 ),
-                             ),
-                         ]
-                         .into_iter()
-                         .collect(),
-                     ),
-                 ),
-             ]
-             .into_iter()
-             .collect(),
-         )));
-     });
- }
+        assert!(args.contains(&Value::object(
+            vec![
+                ("name", Value::scalar("arg")),
+                ("description", Value::scalar("The arg")),
+                ("defaultValue", Value::null()),
+                (
+                    "type",
+                    Value::object(
+                        vec![
+                            ("name", Value::null()),
+                            (
+                                "ofType",
+                                Value::object(
+                                    vec![("name", Value::scalar("Int"))].into_iter().collect(),
+                                ),
+                            ),
+                        ]
+                        .into_iter()
+                        .collect(),
+                    ),
+                ),
+            ]
+            .into_iter()
+            .collect(),
+        )));
+    });
+}
 
- #[test]
- fn introspect_field_attr_arg_descr_collapse() {
-     run_args_info_query("attrArgDescrCollapse", |args| {
-         assert_eq!(args.len(), 1);
+#[test]
+fn introspect_field_attr_arg_descr_collapse() {
+    run_args_info_query("attrArgDescrCollapse", |args| {
+        assert_eq!(args.len(), 1);
 
-         assert!(args.contains(&Value::object(
-             vec![
-                 ("name", Value::scalar("arg")),
-                 ("description", Value::scalar("The arg\nand more details")),
-                 ("defaultValue", Value::null()),
-                 (
-                     "type",
-                     Value::object(
-                         vec![
-                             ("name", Value::null()),
-                             (
-                                 "ofType",
-                                 Value::object(
-                                     vec![("name", Value::scalar("Int"))].into_iter().collect(),
-                                 ),
-                             ),
-                         ]
-                         .into_iter()
-                         .collect(),
-                     ),
-                 ),
-             ]
-             .into_iter()
-             .collect(),
-         )));
-     });
- }
+        assert!(args.contains(&Value::object(
+            vec![
+                ("name", Value::scalar("arg")),
+                ("description", Value::scalar("The arg\nand more details")),
+                ("defaultValue", Value::null()),
+                (
+                    "type",
+                    Value::object(
+                        vec![
+                            ("name", Value::null()),
+                            (
+                                "ofType",
+                                Value::object(
+                                    vec![("name", Value::scalar("Int"))].into_iter().collect(),
+                                ),
+                            ),
+                        ]
+                        .into_iter()
+                        .collect(),
+                    ),
+                ),
+            ]
+            .into_iter()
+            .collect(),
+        )));
+    });
+}
 
 #[test]
 fn introspect_field_arg_with_default() {
diff --git a/juniper/src/macros/tests/union.rs b/juniper/src/macros/tests/union.rs
index 0e0aac7d..a8fd120d 100644
--- a/juniper/src/macros/tests/union.rs
+++ b/juniper/src/macros/tests/union.rs
@@ -10,7 +10,6 @@ Syntax to validate:
 *
 */
 
-
 use std::marker::PhantomData;
 
 use crate::{
@@ -50,16 +49,20 @@ impl Concrete {
 impl CustomName {
     fn resolve(&self) {
         match self {
-            Concrete => match *self { CustomName::Concrete(ref c) => Some(c) },
+            Concrete => match *self {
+                CustomName::Concrete(ref c) => Some(c),
+            },
         }
     }
 }
 
 #[crate::union_internal]
-impl<'a> WithLifetime<'a>{
+impl<'a> WithLifetime<'a> {
     fn resolve(&self) {
         match self {
-            Concrete => match *self { WithLifetime::Int(_) => Some(&Concrete) },
+            Concrete => match *self {
+                WithLifetime::Int(_) => Some(&Concrete),
+            },
         }
     }
 }
@@ -68,7 +71,9 @@ impl<'a> WithLifetime<'a>{
 impl<T> WithGenerics<T> {
     fn resolve(&self) {
         match self {
-            Concrete => match *self { WithGenerics::Generic(_) => Some(&Concrete) }
+            Concrete => match *self {
+                WithGenerics::Generic(_) => Some(&Concrete),
+            },
         }
     }
 }
@@ -77,7 +82,9 @@ impl<T> WithGenerics<T> {
 impl DescriptionFirst {
     fn resolve(&self) {
         match self {
-            Concrete => match *self { DescriptionFirst::Concrete(ref c) => Some(c) },
+            Concrete => match *self {
+                DescriptionFirst::Concrete(ref c) => Some(c),
+            },
         }
     }
 }
@@ -211,4 +218,3 @@ fn introspect_description_first() {
         )));
     });
 }
-
diff --git a/juniper/src/schema/schema.rs b/juniper/src/schema/schema.rs
index 23b36c8e..d9501474 100644
--- a/juniper/src/schema/schema.rs
+++ b/juniper/src/schema/schema.rs
@@ -98,13 +98,12 @@ where
     ) -> ExecutionResult<S> {
         use futures::future::{ready, FutureExt};
         match field_name {
-            "__schema" | "__type" => {
-                self.resolve_field(info, field_name, arguments, executor)
+            "__schema" | "__type" => self.resolve_field(info, field_name, arguments, executor),
+            _ => {
+                self.query_type
+                    .resolve_field_async(info, field_name, arguments, executor)
+                    .await
             }
-            _ => self
-                .query_type
-                .resolve_field_async(info, field_name, arguments, executor)
-                .await,
         }
     }
 }
diff --git a/juniper/src/tests/introspection_tests.rs b/juniper/src/tests/introspection_tests.rs
index a33496f9..8df5e052 100644
--- a/juniper/src/tests/introspection_tests.rs
+++ b/juniper/src/tests/introspection_tests.rs
@@ -234,7 +234,7 @@ fn test_introspection_possible_types() {
     assert_eq!(possible_types, vec!["Human", "Droid"].into_iter().collect());
 }
 
-/* 
+/*
  * FIXME: make this work again
 #[test]
 fn test_builtin_introspection_query() {
diff --git a/juniper/src/types/async_await.rs b/juniper/src/types/async_await.rs
index 53bc9008..19de1322 100644
--- a/juniper/src/types/async_await.rs
+++ b/juniper/src/types/async_await.rs
@@ -1,8 +1,8 @@
-use async_trait::async_trait;
 use crate::{
     ast::{Directive, FromInputValue, InputValue, Selection},
     value::{Object, ScalarRefValue, ScalarValue, Value},
 };
+use async_trait::async_trait;
 
 use crate::{
     executor::{ExecutionResult, Executor},
@@ -239,12 +239,14 @@ where
                 );
 
                 if let Some(ref type_condition) = fragment.type_condition {
-                    let sub_result = instance.resolve_into_type_async(
-                        info,
-                        type_condition.item,
-                        Some(&fragment.selection_set[..]),
-                        &sub_exec,
-                    ).await;
+                    let sub_result = instance
+                        .resolve_into_type_async(
+                            info,
+                            type_condition.item,
+                            Some(&fragment.selection_set[..]),
+                            &sub_exec,
+                        )
+                        .await;
 
                     if let Ok(Value::Object(obj)) = sub_result {
                         for (k, v) in obj {
diff --git a/juniper/src/types/pointers.rs b/juniper/src/types/pointers.rs
index 7b47fcb6..ed1ecd02 100644
--- a/juniper/src/types/pointers.rs
+++ b/juniper/src/types/pointers.rs
@@ -153,13 +153,8 @@ where
         arguments: &'b Arguments<'b, S>,
         executor: &'b Executor<'b, <Self as crate::GraphQLType<S>>::Context, S>,
     ) -> ExecutionResult<S> {
-        crate::GraphQLTypeAsync::resolve_field_async(
-            &**self,
-            info,
-            field_name,
-            arguments,
-            executor
-        ).await
+        crate::GraphQLTypeAsync::resolve_field_async(&**self, info, field_name, arguments, executor)
+            .await
     }
 
     async fn resolve_async<'a>(
@@ -168,12 +163,7 @@ where
         selection_set: Option<&'a [Selection<'a, S>]>,
         executor: &'a Executor<'a, <Self as crate::GraphQLType<S>>::Context, S>,
     ) -> Value<S> {
-        crate::GraphQLTypeAsync::resolve_async(
-            &**self,
-            info,
-            selection_set,
-            executor
-        ).await
+        crate::GraphQLTypeAsync::resolve_async(&**self, info, selection_set, executor).await
     }
 }
 
diff --git a/juniper_codegen/src/impl_object.rs b/juniper_codegen/src/impl_object.rs
index db7ad2e1..3613d36b 100644
--- a/juniper_codegen/src/impl_object.rs
+++ b/juniper_codegen/src/impl_object.rs
@@ -41,18 +41,15 @@ pub fn build_object(args: TokenStream, body: TokenStream, is_internal: bool) ->
         }
     }
 
-
-    let name =
-    if let Some(name) = impl_attrs.name.as_ref(){
+    let name = if let Some(name) = impl_attrs.name.as_ref() {
         name.to_string()
-    }
-    else {
+    } else {
         if let Some(ident) = util::name_of_type(&*_impl.self_ty) {
             ident.to_string()
         } else {
-                panic!("Could not determine a name for the object type: specify one with #[juniper::object(name = \"SomeName\")");
-            }
-        };
+            panic!("Could not determine a name for the object type: specify one with #[juniper::object(name = \"SomeName\")");
+        }
+    };
 
     let target_type = *_impl.self_ty.clone();
 
diff --git a/juniper_codegen/src/impl_union.rs b/juniper_codegen/src/impl_union.rs
index 58edade1..a2418e7a 100644
--- a/juniper_codegen/src/impl_union.rs
+++ b/juniper_codegen/src/impl_union.rs
@@ -1,7 +1,7 @@
 use proc_macro::TokenStream;
 
 use proc_macro_error::MacroError;
-use quote::{quote};
+use quote::quote;
 use syn::spanned::Spanned;
 
 use crate::util;
@@ -39,7 +39,7 @@ impl syn::parse::Parse for ResolveBody {
         body.parse::<syn::token::Match>()?;
         body.parse::<syn::token::SelfValue>()?;
 
-        let match_body; 
+        let match_body;
         syn::braced!( match_body in body );
 
         let mut variants = Vec::new();
@@ -67,7 +67,6 @@ pub fn impl_union(
     attrs: TokenStream,
     body: TokenStream,
 ) -> Result<TokenStream, MacroError> {
-
     // We are re-using the object attributes since they are almost the same.
     let attrs = syn::parse::<util::ObjectAttributes>(attrs)?;
 
@@ -76,7 +75,8 @@ pub fn impl_union(
     if item.items.len() != 1 {
         return Err(MacroError::new(
             item.span(),
-            "Invalid impl body: expected one method with signature: fn resolve(&self) { ... }".to_string(),
+            "Invalid impl body: expected one method with signature: fn resolve(&self) { ... }"
+                .to_string(),
         ));
     }
 
@@ -92,7 +92,7 @@ pub fn impl_union(
             "Expected a path ending in a simple type identifier".to_string(),
         )
     })?;
-    let name = attrs.name.unwrap_or_else(||  ty_ident.to_string());
+    let name = attrs.name.unwrap_or_else(|| ty_ident.to_string());
 
     let juniper = util::juniper_path(is_internal);
 
@@ -130,7 +130,9 @@ pub fn impl_union(
         .scalar
         .as_ref()
         .map(|s| quote!( #s ))
-        .unwrap_or_else(|| { quote! { #juniper::DefaultScalarValue } });
+        .unwrap_or_else(|| {
+            quote! { #juniper::DefaultScalarValue }
+        });
 
     let mut generics = item.generics.clone();
     if attrs.scalar.is_some() {
@@ -139,10 +141,12 @@ pub fn impl_union(
         // compatible with ScalarValueRef.
         // This is done to prevent the user from having to specify this
         // manually.
-        let where_clause = generics.where_clause.get_or_insert(syn::parse_quote!(where));
-        where_clause.predicates.push(
-            syn::parse_quote!(for<'__b> &'__b #scalar: #juniper::ScalarRefValue<'__b>),
-        );
+        let where_clause = generics
+            .where_clause
+            .get_or_insert(syn::parse_quote!(where));
+        where_clause
+            .predicates
+            .push(syn::parse_quote!(for<'__b> &'__b #scalar: #juniper::ScalarRefValue<'__b>));
     }
 
     let (impl_generics, _, where_clause) = generics.split_for_impl();
@@ -151,10 +155,13 @@ pub fn impl_union(
         Some(value) => quote!( .description( #value ) ),
         None => quote!(),
     };
-    let context = attrs.context.map(|c| quote!{ #c } ).unwrap_or_else(|| quote!{ () });
+    let context = attrs
+        .context
+        .map(|c| quote! { #c })
+        .unwrap_or_else(|| quote! { () });
 
     let output = quote! {
-        impl #impl_generics #juniper::GraphQLType<#scalar> for #ty #where_clause 
+        impl #impl_generics #juniper::GraphQLType<#scalar> for #ty #where_clause
         {
             type Context = #context;
             type TypeInfo = ();
diff --git a/juniper_codegen/src/lib.rs b/juniper_codegen/src/lib.rs
index cf85bfb7..a31adb50 100644
--- a/juniper_codegen/src/lib.rs
+++ b/juniper_codegen/src/lib.rs
@@ -389,4 +389,3 @@ pub fn union_internal(attrs: TokenStream, body: TokenStream) -> TokenStream {
     };
     output
 }
-