From 6fa6c20fa7ef4ed3c7a941d6f8650dbd3c19de81 Mon Sep 17 00:00:00 2001 From: danieleades <33452915+danieleades@users.noreply.github.com> Date: Wed, 18 Dec 2019 04:37:46 +0000 Subject: [PATCH] address clippy::all lints (#486) --- integration_tests/async_await/src/main.rs | 5 ++--- juniper/src/tests/model.rs | 5 +---- juniper_codegen/src/impl_object.rs | 2 +- juniper_codegen/src/util/mod.rs | 4 +--- juniper_iron/src/lib.rs | 22 +++++++++++----------- rustfmt.toml | 1 + 6 files changed, 17 insertions(+), 22 deletions(-) diff --git a/integration_tests/async_await/src/main.rs b/integration_tests/async_await/src/main.rs index ae973c1a..aee9fde3 100644 --- a/integration_tests/async_await/src/main.rs +++ b/integration_tests/async_await/src/main.rs @@ -20,14 +20,13 @@ impl User { } async fn friends(&self) -> Vec<User> { - let friends = (0..10) + (0..10) .map(|index| User { id: index, name: format!("user{}", index), kind: UserKind::User, }) - .collect(); - friends + .collect() } async fn kind(&self) -> &UserKind { diff --git a/juniper/src/tests/model.rs b/juniper/src/tests/model.rs index 3e8f94b5..509b8a4d 100644 --- a/juniper/src/tests/model.rs +++ b/juniper/src/tests/model.rs @@ -242,10 +242,7 @@ impl Database { ), ); - Database { - humans: humans, - droids: droids, - } + Database { humans, droids } } pub fn get_hero(&self, episode: Option<Episode>) -> &dyn Character { diff --git a/juniper_codegen/src/impl_object.rs b/juniper_codegen/src/impl_object.rs index 6df56909..35bea849 100644 --- a/juniper_codegen/src/impl_object.rs +++ b/juniper_codegen/src/impl_object.rs @@ -58,7 +58,7 @@ pub fn build_object(args: TokenStream, body: TokenStream, is_internal: bool) -> .or(util::get_doc_comment(&_impl.attrs)); let mut definition = util::GraphQLTypeDefiniton { - name: name, + name, _type: target_type.clone(), context: impl_attrs.context, scalar: impl_attrs.scalar, diff --git a/juniper_codegen/src/util/mod.rs b/juniper_codegen/src/util/mod.rs index 97d993c3..9dcbed13 100644 --- a/juniper_codegen/src/util/mod.rs +++ b/juniper_codegen/src/util/mod.rs @@ -509,9 +509,7 @@ impl parse::Parse for FieldAttribute { } else { None }; - Ok(FieldAttribute::Deprecation(DeprecationAttr { - reason: reason, - })) + Ok(FieldAttribute::Deprecation(DeprecationAttr { reason })) } "skip" => Ok(FieldAttribute::Skip(ident)), "arguments" => { diff --git a/juniper_iron/src/lib.rs b/juniper_iron/src/lib.rs index a7802038..e702da18 100644 --- a/juniper_iron/src/lib.rs +++ b/juniper_iron/src/lib.rs @@ -155,11 +155,11 @@ where QueryT: GraphQLType<S, Context = CtxT>, MutationT: GraphQLType<S, Context = CtxT>, { - match self { - &GraphQLBatchRequest::Single(ref request) => { + match *self { + GraphQLBatchRequest::Single(ref request) => { GraphQLBatchResponse::Single(request.execute(root_node, context)) } - &GraphQLBatchRequest::Batch(ref requests) => GraphQLBatchResponse::Batch( + GraphQLBatchRequest::Batch(ref requests) => GraphQLBatchResponse::Batch( requests .iter() .map(|request| request.execute(root_node, context)) @@ -174,11 +174,11 @@ where S: ScalarValue, { fn is_ok(&self) -> bool { - match self { - &GraphQLBatchResponse::Single(ref response) => response.is_ok(), - &GraphQLBatchResponse::Batch(ref responses) => responses - .iter() - .fold(true, |ok, response| ok && response.is_ok()), + match *self { + GraphQLBatchResponse::Single(ref response) => response.is_ok(), + GraphQLBatchResponse::Batch(ref responses) => { + responses.iter().all(|response| response.is_ok()) + } } } } @@ -263,7 +263,7 @@ where /// the schema needs to execute the query. pub fn new(context_factory: CtxFactory, query: Query, mutation: Mutation) -> Self { GraphQLHandler { - context_factory: context_factory, + context_factory, root_node: RootNode::new(query, mutation), } } @@ -513,9 +513,9 @@ mod tests { let body = response::extract_body_to_string(response); http_tests::TestResponse { - status_code: status_code, + status_code, body: Some(body), - content_type: content_type, + content_type, } } diff --git a/rustfmt.toml b/rustfmt.toml index 7d2cf549..8586c40c 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -1 +1,2 @@ merge_imports = true +use_field_init_shorthand = true