From 150227f357c275f36411602701b71079ff8761de Mon Sep 17 00:00:00 2001 From: tyranron Date: Fri, 27 Jan 2023 19:14:46 +0200 Subject: [PATCH] Make Clippy happy for 1.67 Rust --- juniper/src/ast.rs | 4 +-- juniper/src/executor/look_ahead.rs | 12 ++++---- juniper/src/executor/mod.rs | 4 +-- juniper/src/lib.rs | 4 +-- juniper/src/parser/value.rs | 10 +++---- juniper/src/types/async_await.rs | 2 +- juniper/src/types/base.rs | 9 +++--- juniper/src/types/subscriptions.rs | 2 +- juniper/src/types/utilities.rs | 2 +- juniper/src/validation/context.rs | 4 +-- juniper/src/validation/input_value.rs | 14 ++++----- .../rules/arguments_of_correct_type.rs | 2 +- .../rules/default_values_of_correct_type.rs | 2 +- .../validation/rules/known_argument_names.rs | 2 +- .../src/validation/rules/known_type_names.rs | 6 ++-- .../rules/no_undefined_variables.rs | 6 ++-- .../validation/rules/no_unused_variables.rs | 4 +-- .../rules/overlapping_fields_can_be_merged.rs | 29 ++++++------------- .../rules/provided_non_null_arguments.rs | 4 +-- .../validation/rules/unique_argument_names.rs | 2 +- .../rules/unique_input_field_names.rs | 2 +- .../validation/rules/unique_variable_names.rs | 2 +- .../rules/variables_are_input_types.rs | 2 +- .../rules/variables_in_allowed_position.rs | 17 +++++------ 24 files changed, 66 insertions(+), 81 deletions(-) diff --git a/juniper/src/ast.rs b/juniper/src/ast.rs index 68eb1be4..3a3c4de3 100644 --- a/juniper/src/ast.rs +++ b/juniper/src/ast.rs @@ -567,8 +567,8 @@ impl<'a, S> Arguments<'a, S> { pub fn get(&self, key: &str) -> Option<&Spanning>> { self.items .iter() - .filter(|&&(ref k, _)| k.item == key) - .map(|&(_, ref v)| v) + .filter(|&(k, _)| k.item == key) + .map(|(_, v)| v) .next() } } diff --git a/juniper/src/executor/look_ahead.rs b/juniper/src/executor/look_ahead.rs index 20437082..ac402323 100644 --- a/juniper/src/executor/look_ahead.rs +++ b/juniper/src/executor/look_ahead.rs @@ -52,7 +52,7 @@ where ), InputValue::Object(ref o) => LookAheadValue::Object( o.iter() - .map(|&(ref n, ref i)| { + .map(|(n, i)| { ( &n.item as &str, LookAheadValue::from_input_value(&i.item, vars), @@ -76,7 +76,7 @@ where S: ScalarValue, { pub(super) fn new( - &(ref name, ref value): &'a (Spanning<&'a str>, Spanning>), + (name, value): &'a (Spanning<&'a str>, Spanning>), vars: &'a Variables, ) -> Self { LookAheadArgument { @@ -143,12 +143,12 @@ where let d = &d.item; let arguments = &d.arguments; match (d.name.item, arguments) { - ("include", &Some(ref a)) => a + ("include", Some(a)) => a .item .items .iter() .find(|item| item.0.item == "if") - .map(|&(_, ref v)| { + .map(|(_, v)| { if let LookAheadValue::Scalar(s) = LookAheadValue::from_input_value(&v.item, vars) { @@ -158,12 +158,12 @@ where } }) .unwrap_or(false), - ("skip", &Some(ref a)) => a + ("skip", Some(a)) => a .item .items .iter() .find(|item| item.0.item == "if") - .map(|&(_, ref v)| { + .map(|(_, v)| { if let LookAheadValue::Scalar(b) = LookAheadValue::from_input_value(&v.item, vars) { diff --git a/juniper/src/executor/mod.rs b/juniper/src/executor/mod.rs index 9ab412d4..6230a8b4 100644 --- a/juniper/src/executor/mod.rs +++ b/juniper/src/executor/mod.rs @@ -940,7 +940,7 @@ where defs.item .items .iter() - .filter_map(|&(ref name, ref def)| { + .filter_map(|(name, def)| { def.default_value .as_ref() .map(|i| (name.item.into(), i.item.clone())) @@ -1087,7 +1087,7 @@ where defs.item .items .iter() - .filter_map(|&(ref name, ref def)| { + .filter_map(|(name, def)| { def.default_value .as_ref() .map(|i| (name.item.into(), i.item.clone())) diff --git a/juniper/src/lib.rs b/juniper/src/lib.rs index ac1e0329..43326eb3 100644 --- a/juniper/src/lib.rs +++ b/juniper/src/lib.rs @@ -268,8 +268,8 @@ where } /// Execute the reference introspection query in the provided schema -pub fn introspect<'a, S, QueryT, MutationT, SubscriptionT>( - root_node: &'a RootNode, +pub fn introspect( + root_node: &RootNode, context: &QueryT::Context, format: IntrospectionFormat, ) -> Result<(Value, Vec>), GraphQLError> diff --git a/juniper/src/parser/value.rs b/juniper/src/parser/value.rs index f94f65c2..21f4518f 100644 --- a/juniper/src/parser/value.rs +++ b/juniper/src/parser/value.rs @@ -38,7 +38,7 @@ where item: Token::CurlyOpen, .. }, - Some(&MetaType::InputObject(ref o)), + Some(MetaType::InputObject(o)), ) => parse_object_literal(parser, is_const, schema, Some(o)), ( &Spanning { @@ -52,7 +52,7 @@ where item: Token::Scalar(_), .. }, - Some(&MetaType::Scalar(ref s)), + Some(MetaType::Scalar(s)), ) => { if let Spanning { item: Token::Scalar(scalar), @@ -210,7 +210,7 @@ where { let result = match token { ScalarToken::String(_) => { - if let Some(&MetaType::Scalar(ref s)) = schema.concrete_type_by_name("String") { + if let Some(MetaType::Scalar(s)) = schema.concrete_type_by_name("String") { (s.parse_fn)(token).map(InputValue::Scalar) } else { Err(ParseError::ExpectedScalarError( @@ -219,7 +219,7 @@ where } } ScalarToken::Int(_) => { - if let Some(&MetaType::Scalar(ref s)) = schema.concrete_type_by_name("Int") { + if let Some(MetaType::Scalar(s)) = schema.concrete_type_by_name("Int") { (s.parse_fn)(token).map(InputValue::Scalar) } else { Err(ParseError::ExpectedScalarError( @@ -228,7 +228,7 @@ where } } ScalarToken::Float(_) => { - if let Some(&MetaType::Scalar(ref s)) = schema.concrete_type_by_name("Float") { + if let Some(MetaType::Scalar(s)) = schema.concrete_type_by_name("Float") { (s.parse_fn)(token).map(InputValue::Scalar) } else { Err(ParseError::ExpectedScalarError( diff --git a/juniper/src/types/async_await.rs b/juniper/src/types/async_await.rs index 827a1d50..28fa6e90 100644 --- a/juniper/src/types/async_await.rs +++ b/juniper/src/types/async_await.rs @@ -244,7 +244,7 @@ where f.arguments.as_ref().map(|m| { m.item .iter() - .filter_map(|&(ref k, ref v)| { + .filter_map(|(k, v)| { v.item.clone().into_const(exec_vars).map(|v| (k.item, v)) }) .collect() diff --git a/juniper/src/types/base.rs b/juniper/src/types/base.rs index 9d54fee0..795bdb40 100644 --- a/juniper/src/types/base.rs +++ b/juniper/src/types/base.rs @@ -472,7 +472,7 @@ where f.arguments.as_ref().map(|m| { m.item .iter() - .filter_map(|&(ref k, ref v)| { + .filter_map(|(k, v)| { v.item.clone().into_const(exec_vars).map(|v| (k.item, v)) }) .collect() @@ -596,10 +596,9 @@ pub(super) fn is_excluded( where S: ScalarValue, { - if let Some(ref directives) = *directives { - for &Spanning { - item: ref directive, - .. + if let Some(directives) = directives { + for Spanning { + item: directive, .. } in directives { let condition: bool = directive diff --git a/juniper/src/types/subscriptions.rs b/juniper/src/types/subscriptions.rs index e1f42fdf..63fa14e4 100644 --- a/juniper/src/types/subscriptions.rs +++ b/juniper/src/types/subscriptions.rs @@ -316,7 +316,7 @@ where f.arguments.as_ref().map(|m| { m.item .iter() - .filter_map(|&(ref k, ref v)| { + .filter_map(|(k, v)| { v.item.clone().into_const(exec_vars).map(|v| (k.item, v)) }) .collect() diff --git a/juniper/src/types/utilities.rs b/juniper/src/types/utilities.rs index f1be0792..f0e44b1f 100644 --- a/juniper/src/types/utilities.rs +++ b/juniper/src/types/utilities.rs @@ -80,7 +80,7 @@ where }) .collect::>(); - let all_types_ok = obj.iter().all(|&(ref key, ref value)| { + let all_types_ok = obj.iter().all(|(key, value)| { remaining_required_fields.remove(&key.item); if let Some(ref arg_type) = input_fields .iter() diff --git a/juniper/src/validation/context.rs b/juniper/src/validation/context.rs index c96c0491..d98c5142 100644 --- a/juniper/src/validation/context.rs +++ b/juniper/src/validation/context.rs @@ -173,7 +173,7 @@ impl<'a, S: Debug> ValidatorContext<'a, S> { #[doc(hidden)] pub fn current_type_literal(&self) -> Option<&Type<'a>> { match self.type_literal_stack.last() { - Some(&Some(ref t)) => Some(t), + Some(Some(t)) => Some(t), _ => None, } } @@ -186,7 +186,7 @@ impl<'a, S: Debug> ValidatorContext<'a, S> { #[doc(hidden)] pub fn current_input_type_literal(&self) -> Option<&Type<'a>> { match self.input_type_literal_stack.last() { - Some(&Some(ref t)) => Some(t), + Some(Some(t)) => Some(t), _ => None, } } diff --git a/juniper/src/validation/input_value.rs b/juniper/src/validation/input_value.rs index 780a0ab3..432126f8 100644 --- a/juniper/src/validation/input_value.rs +++ b/juniper/src/validation/input_value.rs @@ -46,7 +46,7 @@ fn validate_var_defs( ) where S: ScalarValue, { - for &(ref name, ref def) in var_defs.iter() { + for (name, def) in var_defs.iter() { let raw_type_name = def.var_type.item.innermost_name(); match schema.concrete_type_by_name(raw_type_name) { Some(t) if t.is_input() => { @@ -188,12 +188,12 @@ where errors } -fn unify_scalar<'a, S>( +fn unify_scalar( var_name: &str, var_pos: &SourcePosition, value: &InputValue, meta: &ScalarMeta, - path: &Path<'a>, + path: &Path<'_>, ) -> Vec where S: ScalarValue, @@ -231,12 +231,12 @@ where errors } -fn unify_enum<'a, S>( +fn unify_enum( var_name: &str, var_pos: &SourcePosition, value: &InputValue, meta: &EnumMeta, - path: &Path<'a>, + path: &Path<'_>, ) -> Vec where S: ScalarValue, @@ -277,13 +277,13 @@ where errors } -fn unify_input_object<'a, S>( +fn unify_input_object( var_name: &str, var_pos: &SourcePosition, value: &InputValue, meta: &InputObjectMeta, schema: &SchemaType, - path: &Path<'a>, + path: &Path<'_>, ) -> Vec where S: ScalarValue, diff --git a/juniper/src/validation/rules/arguments_of_correct_type.rs b/juniper/src/validation/rules/arguments_of_correct_type.rs index 2c7aadbe..85a8959f 100644 --- a/juniper/src/validation/rules/arguments_of_correct_type.rs +++ b/juniper/src/validation/rules/arguments_of_correct_type.rs @@ -50,7 +50,7 @@ where fn enter_argument( &mut self, ctx: &mut ValidatorContext<'a, S>, - &(ref arg_name, ref arg_value): &'a (Spanning<&'a str>, Spanning>), + (arg_name, arg_value): &'a (Spanning<&'a str>, Spanning>), ) { if let Some(argument_meta) = self .current_args diff --git a/juniper/src/validation/rules/default_values_of_correct_type.rs b/juniper/src/validation/rules/default_values_of_correct_type.rs index 2d15f854..f3d25462 100644 --- a/juniper/src/validation/rules/default_values_of_correct_type.rs +++ b/juniper/src/validation/rules/default_values_of_correct_type.rs @@ -21,7 +21,7 @@ where fn enter_variable_definition( &mut self, ctx: &mut ValidatorContext<'a, S>, - &(ref var_name, ref var_def): &'a (Spanning<&'a str>, VariableDefinition), + (var_name, var_def): &'a (Spanning<&'a str>, VariableDefinition), ) { if let Some(Spanning { item: ref var_value, diff --git a/juniper/src/validation/rules/known_argument_names.rs b/juniper/src/validation/rules/known_argument_names.rs index d652caf3..3239b514 100644 --- a/juniper/src/validation/rules/known_argument_names.rs +++ b/juniper/src/validation/rules/known_argument_names.rs @@ -71,7 +71,7 @@ where fn enter_argument( &mut self, ctx: &mut ValidatorContext<'a, S>, - &(ref arg_name, _): &'a (Spanning<&'a str>, Spanning>), + (arg_name, _): &'a (Spanning<&'a str>, Spanning>), ) { if let Some((ref pos, args)) = self.current_args { if !args.iter().any(|a| a.name == arg_name.item) { diff --git a/juniper/src/validation/rules/known_type_names.rs b/juniper/src/validation/rules/known_type_names.rs index 4f2dffc2..7f926b59 100644 --- a/juniper/src/validation/rules/known_type_names.rs +++ b/juniper/src/validation/rules/known_type_names.rs @@ -38,15 +38,15 @@ where fn enter_variable_definition( &mut self, ctx: &mut ValidatorContext<'a, S>, - &(_, ref var_def): &'a (Spanning<&'a str>, VariableDefinition), + (_, var_def): &'a (Spanning<&'a str>, VariableDefinition), ) { let type_name = var_def.var_type.item.innermost_name(); validate_type(ctx, type_name, &var_def.var_type.start); } } -fn validate_type<'a, S: Debug>( - ctx: &mut ValidatorContext<'a, S>, +fn validate_type( + ctx: &mut ValidatorContext<'_, S>, type_name: &str, location: &SourcePosition, ) { diff --git a/juniper/src/validation/rules/no_undefined_variables.rs b/juniper/src/validation/rules/no_undefined_variables.rs index 6e382b23..64c45519 100644 --- a/juniper/src/validation/rules/no_undefined_variables.rs +++ b/juniper/src/validation/rules/no_undefined_variables.rs @@ -85,7 +85,7 @@ where S: ScalarValue, { fn exit_document(&mut self, ctx: &mut ValidatorContext<'a, S>, _: &'a Document) { - for (op_name, &(ref pos, ref def_vars)) in &self.defined_variables { + for (op_name, (pos, def_vars)) in &self.defined_variables { let mut unused = Vec::new(); let mut visited = HashSet::new(); self.find_undef_vars( @@ -141,7 +141,7 @@ where fn enter_variable_definition( &mut self, _: &mut ValidatorContext<'a, S>, - &(ref var_name, _): &'a (Spanning<&'a str>, VariableDefinition), + (var_name, _): &'a (Spanning<&'a str>, VariableDefinition), ) { if let Some(Scope::Operation(ref name)) = self.current_scope { if let Some(&mut (_, ref mut vars)) = self.defined_variables.get_mut(name) { @@ -153,7 +153,7 @@ where fn enter_argument( &mut self, _: &mut ValidatorContext<'a, S>, - &(_, ref value): &'a (Spanning<&'a str>, Spanning>), + (_, value): &'a (Spanning<&'a str>, Spanning>), ) { if let Some(ref scope) = self.current_scope { self.used_variables diff --git a/juniper/src/validation/rules/no_unused_variables.rs b/juniper/src/validation/rules/no_unused_variables.rs index 81b7dfb3..96294be3 100644 --- a/juniper/src/validation/rules/no_unused_variables.rs +++ b/juniper/src/validation/rules/no_unused_variables.rs @@ -139,7 +139,7 @@ where fn enter_variable_definition( &mut self, _: &mut ValidatorContext<'a, S>, - &(ref var_name, _): &'a (Spanning<&'a str>, VariableDefinition), + (var_name, _): &'a (Spanning<&'a str>, VariableDefinition), ) { if let Some(Scope::Operation(ref name)) = self.current_scope { if let Some(vars) = self.defined_variables.get_mut(name) { @@ -151,7 +151,7 @@ where fn enter_argument( &mut self, _: &mut ValidatorContext<'a, S>, - &(_, ref value): &'a (Spanning<&'a str>, Spanning>), + (_, value): &'a (Spanning<&'a str>, Spanning>), ) { if let Some(ref scope) = self.current_scope { self.used_variables diff --git a/juniper/src/validation/rules/overlapping_fields_can_be_merged.rs b/juniper/src/validation/rules/overlapping_fields_can_be_merged.rs index b8360ca0..0555f6e8 100644 --- a/juniper/src/validation/rules/overlapping_fields_can_be_merged.rs +++ b/juniper/src/validation/rules/overlapping_fields_can_be_merged.rs @@ -447,8 +447,7 @@ impl<'a, S: Debug> OverlappingFieldsCanBeMerged<'a, S> { } } - if let (&Some(ref s1), &Some(ref s2)) = (&ast1.item.selection_set, &ast2.item.selection_set) - { + if let (Some(s1), Some(s2)) = (&ast1.item.selection_set, &ast2.item.selection_set) { let conflicts = self.find_conflicts_between_sub_selection_sets( mutually_exclusive, t1.map(Type::innermost_name), @@ -547,19 +546,11 @@ impl<'a, S: Debug> OverlappingFieldsCanBeMerged<'a, S> { ), vec![*pos1] .into_iter() - .chain( - conflicts - .iter() - .flat_map(|&Conflict(_, ref fs1, _)| fs1.clone()), - ) + .chain(conflicts.iter().flat_map(|Conflict(_, fs1, _)| fs1.clone())) .collect(), vec![*pos2] .into_iter() - .chain( - conflicts - .iter() - .flat_map(|&Conflict(_, _, ref fs2)| fs2.clone()), - ) + .chain(conflicts.iter().flat_map(|Conflict(_, _, fs2)| fs2.clone())) .collect(), )) } @@ -615,10 +606,8 @@ impl<'a, S: Debug> OverlappingFieldsCanBeMerged<'a, S> { return false; } - args1.iter().all(|&(ref n1, ref v1)| { - if let Some(&(_, ref v2)) = - args2.iter().find(|&&(ref n2, _)| n1.item == n2.item) - { + args1.iter().all(|(n1, v1)| { + if let Some((_, v2)) = args2.iter().find(|&(n2, _)| n1.item == n2.item) { v1.item.unlocated_eq(&v2.item) } else { false @@ -756,11 +745,11 @@ fn error_message(reason_name: &str, reason: &ConflictReasonMessage) -> String { } fn format_reason(reason: &ConflictReasonMessage) -> String { - match *reason { - ConflictReasonMessage::Message(ref name) => name.clone(), - ConflictReasonMessage::Nested(ref nested) => nested + match reason { + ConflictReasonMessage::Message(name) => name.clone(), + ConflictReasonMessage::Nested(nested) => nested .iter() - .map(|&ConflictReason(ref name, ref subreason)| { + .map(|ConflictReason(name, subreason)| { format!( r#"subfields "{name}" conflict because {}"#, format_reason(subreason), diff --git a/juniper/src/validation/rules/provided_non_null_arguments.rs b/juniper/src/validation/rules/provided_non_null_arguments.rs index 35672e18..6c8d07a9 100644 --- a/juniper/src/validation/rules/provided_non_null_arguments.rs +++ b/juniper/src/validation/rules/provided_non_null_arguments.rs @@ -52,8 +52,8 @@ where ) { let directive_name = &directive.item.name.item; - if let Some(&DirectiveType { - arguments: ref meta_args, + if let Some(DirectiveType { + arguments: meta_args, .. }) = ctx.schema.directive_by_name(directive_name) { diff --git a/juniper/src/validation/rules/unique_argument_names.rs b/juniper/src/validation/rules/unique_argument_names.rs index 697e0a27..cbfe510c 100644 --- a/juniper/src/validation/rules/unique_argument_names.rs +++ b/juniper/src/validation/rules/unique_argument_names.rs @@ -32,7 +32,7 @@ where fn enter_argument( &mut self, ctx: &mut ValidatorContext<'a, S>, - &(ref arg_name, _): &'a (Spanning<&'a str>, Spanning>), + (arg_name, _): &'a (Spanning<&'a str>, Spanning>), ) { match self.known_names.entry(arg_name.item) { Entry::Occupied(e) => { diff --git a/juniper/src/validation/rules/unique_input_field_names.rs b/juniper/src/validation/rules/unique_input_field_names.rs index 7108c767..7e3b1d02 100644 --- a/juniper/src/validation/rules/unique_input_field_names.rs +++ b/juniper/src/validation/rules/unique_input_field_names.rs @@ -32,7 +32,7 @@ where fn enter_object_field( &mut self, ctx: &mut ValidatorContext<'a, S>, - &(ref field_name, _): &'a (Spanning, Spanning>), + (field_name, _): &'a (Spanning, Spanning>), ) { if let Some(ref mut known_names) = self.known_name_stack.last_mut() { match known_names.entry(&field_name.item) { diff --git a/juniper/src/validation/rules/unique_variable_names.rs b/juniper/src/validation/rules/unique_variable_names.rs index 738e634b..fa146122 100644 --- a/juniper/src/validation/rules/unique_variable_names.rs +++ b/juniper/src/validation/rules/unique_variable_names.rs @@ -32,7 +32,7 @@ where fn enter_variable_definition( &mut self, ctx: &mut ValidatorContext<'a, S>, - &(ref var_name, _): &'a (Spanning<&'a str>, VariableDefinition), + (var_name, _): &'a (Spanning<&'a str>, VariableDefinition), ) { match self.names.entry(var_name.item) { Entry::Occupied(e) => { diff --git a/juniper/src/validation/rules/variables_are_input_types.rs b/juniper/src/validation/rules/variables_are_input_types.rs index 168119d6..1ba363fe 100644 --- a/juniper/src/validation/rules/variables_are_input_types.rs +++ b/juniper/src/validation/rules/variables_are_input_types.rs @@ -20,7 +20,7 @@ where fn enter_variable_definition( &mut self, ctx: &mut ValidatorContext<'a, S>, - &(ref var_name, ref var_def): &'a (Spanning<&'a str>, VariableDefinition), + (var_name, var_def): &'a (Spanning<&'a str>, VariableDefinition), ) { if let Some(var_type) = ctx .schema diff --git a/juniper/src/validation/rules/variables_in_allowed_position.rs b/juniper/src/validation/rules/variables_in_allowed_position.rs index 776f12db..4accb708 100644 --- a/juniper/src/validation/rules/variables_in_allowed_position.rs +++ b/juniper/src/validation/rules/variables_in_allowed_position.rs @@ -79,18 +79,15 @@ impl<'a, S: fmt::Debug> VariableInAllowedPosition<'a, S> { visited.insert(from.clone()); if let Some(usages) = self.variable_usages.get(from) { - for &(ref var_name, ref var_type) in usages { - if let Some(&&(ref var_def_name, ref var_def)) = var_defs - .iter() - .find(|&&&(ref n, _)| n.item == var_name.item) + for (var_name, var_type) in usages { + if let Some(&(var_def_name, var_def)) = + var_defs.iter().find(|&&(n, _)| n.item == var_name.item) { let expected_type = match (&var_def.default_value, &var_def.var_type.item) { - (&Some(_), &Type::List(ref inner, expected_size)) => { - Type::NonNullList(inner.clone(), expected_size) - } - (&Some(_), &Type::Named(ref inner)) => { - Type::NonNullNamed(Cow::Borrowed(inner)) + (&Some(_), Type::List(inner, expected_size)) => { + Type::NonNullList(inner.clone(), *expected_size) } + (&Some(_), Type::Named(inner)) => Type::NonNullNamed(Cow::Borrowed(inner)), (_, t) => t.clone(), }; @@ -165,7 +162,7 @@ where ctx: &mut ValidatorContext<'a, S>, var_name: Spanning<&'a String>, ) { - if let (&Some(ref scope), Some(input_type)) = + if let (Some(scope), Some(input_type)) = (&self.current_scope, ctx.current_input_type_literal()) { self.variable_usages