Make Clippy happy for 1.67 Rust
This commit is contained in:
parent
9e0b9692a9
commit
150227f357
24 changed files with 66 additions and 81 deletions
|
@ -567,8 +567,8 @@ impl<'a, S> Arguments<'a, S> {
|
|||
pub fn get(&self, key: &str) -> Option<&Spanning<InputValue<S>>> {
|
||||
self.items
|
||||
.iter()
|
||||
.filter(|&&(ref k, _)| k.item == key)
|
||||
.map(|&(_, ref v)| v)
|
||||
.filter(|&(k, _)| k.item == key)
|
||||
.map(|(_, v)| v)
|
||||
.next()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<InputValue<S>>),
|
||||
(name, value): &'a (Spanning<&'a str>, Spanning<InputValue<S>>),
|
||||
vars: &'a Variables<S>,
|
||||
) -> 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)
|
||||
{
|
||||
|
|
|
@ -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()))
|
||||
|
|
|
@ -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<QueryT, MutationT, SubscriptionT, S>,
|
||||
pub fn introspect<S, QueryT, MutationT, SubscriptionT>(
|
||||
root_node: &RootNode<QueryT, MutationT, SubscriptionT, S>,
|
||||
context: &QueryT::Context,
|
||||
format: IntrospectionFormat,
|
||||
) -> Result<(Value<S>, Vec<ExecutionError<S>>), GraphQLError>
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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<S>(
|
|||
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
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -80,7 +80,7 @@ where
|
|||
})
|
||||
.collect::<HashSet<_>>();
|
||||
|
||||
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()
|
||||
|
|
|
@ -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,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ fn validate_var_defs<S>(
|
|||
) 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<S>(
|
||||
var_name: &str,
|
||||
var_pos: &SourcePosition,
|
||||
value: &InputValue<S>,
|
||||
meta: &ScalarMeta<S>,
|
||||
path: &Path<'a>,
|
||||
path: &Path<'_>,
|
||||
) -> Vec<RuleError>
|
||||
where
|
||||
S: ScalarValue,
|
||||
|
@ -231,12 +231,12 @@ where
|
|||
errors
|
||||
}
|
||||
|
||||
fn unify_enum<'a, S>(
|
||||
fn unify_enum<S>(
|
||||
var_name: &str,
|
||||
var_pos: &SourcePosition,
|
||||
value: &InputValue<S>,
|
||||
meta: &EnumMeta<S>,
|
||||
path: &Path<'a>,
|
||||
path: &Path<'_>,
|
||||
) -> Vec<RuleError>
|
||||
where
|
||||
S: ScalarValue,
|
||||
|
@ -277,13 +277,13 @@ where
|
|||
errors
|
||||
}
|
||||
|
||||
fn unify_input_object<'a, S>(
|
||||
fn unify_input_object<S>(
|
||||
var_name: &str,
|
||||
var_pos: &SourcePosition,
|
||||
value: &InputValue<S>,
|
||||
meta: &InputObjectMeta<S>,
|
||||
schema: &SchemaType<S>,
|
||||
path: &Path<'a>,
|
||||
path: &Path<'_>,
|
||||
) -> Vec<RuleError>
|
||||
where
|
||||
S: ScalarValue,
|
||||
|
|
|
@ -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<InputValue<S>>),
|
||||
(arg_name, arg_value): &'a (Spanning<&'a str>, Spanning<InputValue<S>>),
|
||||
) {
|
||||
if let Some(argument_meta) = self
|
||||
.current_args
|
||||
|
|
|
@ -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<S>),
|
||||
(var_name, var_def): &'a (Spanning<&'a str>, VariableDefinition<S>),
|
||||
) {
|
||||
if let Some(Spanning {
|
||||
item: ref var_value,
|
||||
|
|
|
@ -71,7 +71,7 @@ where
|
|||
fn enter_argument(
|
||||
&mut self,
|
||||
ctx: &mut ValidatorContext<'a, S>,
|
||||
&(ref arg_name, _): &'a (Spanning<&'a str>, Spanning<InputValue<S>>),
|
||||
(arg_name, _): &'a (Spanning<&'a str>, Spanning<InputValue<S>>),
|
||||
) {
|
||||
if let Some((ref pos, args)) = self.current_args {
|
||||
if !args.iter().any(|a| a.name == arg_name.item) {
|
||||
|
|
|
@ -38,15 +38,15 @@ where
|
|||
fn enter_variable_definition(
|
||||
&mut self,
|
||||
ctx: &mut ValidatorContext<'a, S>,
|
||||
&(_, ref var_def): &'a (Spanning<&'a str>, VariableDefinition<S>),
|
||||
(_, var_def): &'a (Spanning<&'a str>, VariableDefinition<S>),
|
||||
) {
|
||||
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<S: Debug>(
|
||||
ctx: &mut ValidatorContext<'_, S>,
|
||||
type_name: &str,
|
||||
location: &SourcePosition,
|
||||
) {
|
||||
|
|
|
@ -85,7 +85,7 @@ where
|
|||
S: ScalarValue,
|
||||
{
|
||||
fn exit_document(&mut self, ctx: &mut ValidatorContext<'a, S>, _: &'a Document<S>) {
|
||||
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<S>),
|
||||
(var_name, _): &'a (Spanning<&'a str>, VariableDefinition<S>),
|
||||
) {
|
||||
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<InputValue<S>>),
|
||||
(_, value): &'a (Spanning<&'a str>, Spanning<InputValue<S>>),
|
||||
) {
|
||||
if let Some(ref scope) = self.current_scope {
|
||||
self.used_variables
|
||||
|
|
|
@ -139,7 +139,7 @@ where
|
|||
fn enter_variable_definition(
|
||||
&mut self,
|
||||
_: &mut ValidatorContext<'a, S>,
|
||||
&(ref var_name, _): &'a (Spanning<&'a str>, VariableDefinition<S>),
|
||||
(var_name, _): &'a (Spanning<&'a str>, VariableDefinition<S>),
|
||||
) {
|
||||
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<InputValue<S>>),
|
||||
(_, value): &'a (Spanning<&'a str>, Spanning<InputValue<S>>),
|
||||
) {
|
||||
if let Some(ref scope) = self.current_scope {
|
||||
self.used_variables
|
||||
|
|
|
@ -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),
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -32,7 +32,7 @@ where
|
|||
fn enter_argument(
|
||||
&mut self,
|
||||
ctx: &mut ValidatorContext<'a, S>,
|
||||
&(ref arg_name, _): &'a (Spanning<&'a str>, Spanning<InputValue<S>>),
|
||||
(arg_name, _): &'a (Spanning<&'a str>, Spanning<InputValue<S>>),
|
||||
) {
|
||||
match self.known_names.entry(arg_name.item) {
|
||||
Entry::Occupied(e) => {
|
||||
|
|
|
@ -32,7 +32,7 @@ where
|
|||
fn enter_object_field(
|
||||
&mut self,
|
||||
ctx: &mut ValidatorContext<'a, S>,
|
||||
&(ref field_name, _): &'a (Spanning<String>, Spanning<InputValue<S>>),
|
||||
(field_name, _): &'a (Spanning<String>, Spanning<InputValue<S>>),
|
||||
) {
|
||||
if let Some(ref mut known_names) = self.known_name_stack.last_mut() {
|
||||
match known_names.entry(&field_name.item) {
|
||||
|
|
|
@ -32,7 +32,7 @@ where
|
|||
fn enter_variable_definition(
|
||||
&mut self,
|
||||
ctx: &mut ValidatorContext<'a, S>,
|
||||
&(ref var_name, _): &'a (Spanning<&'a str>, VariableDefinition<S>),
|
||||
(var_name, _): &'a (Spanning<&'a str>, VariableDefinition<S>),
|
||||
) {
|
||||
match self.names.entry(var_name.item) {
|
||||
Entry::Occupied(e) => {
|
||||
|
|
|
@ -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<S>),
|
||||
(var_name, var_def): &'a (Spanning<&'a str>, VariableDefinition<S>),
|
||||
) {
|
||||
if let Some(var_type) = ctx
|
||||
.schema
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue