Clippy clean
This commit is contained in:
parent
490533b640
commit
386b0b2876
|
@ -4,6 +4,7 @@
|
|||
//! It uses the [pest](https://crates.io/crates/pest) crate to parse the input and then transforms
|
||||
//! it into Rust types.
|
||||
#![warn(missing_docs)]
|
||||
#![allow(clippy::unnecessary_wraps)]
|
||||
#![forbid(unsafe_code)]
|
||||
|
||||
use crate::types::OperationType;
|
||||
|
|
|
@ -68,8 +68,10 @@ use futures_util::lock::Mutex;
|
|||
|
||||
use fnv::FnvHashMap;
|
||||
|
||||
type ResSender<K, T> =
|
||||
oneshot::Sender<Result<HashMap<K, <T as Loader<K>>::Value>, <T as Loader<K>>::Error>>;
|
||||
#[allow(clippy::type_complexity)]
|
||||
struct ResSender<K: Send + Hash + Eq + Clone + 'static, T: Loader<K>>(
|
||||
oneshot::Sender<Result<HashMap<K, T::Value>, T::Error>>,
|
||||
);
|
||||
|
||||
struct Requests<K: Send + Hash + Eq + Clone + 'static, T: Loader<K>> {
|
||||
keys: HashSet<K>,
|
||||
|
@ -95,12 +97,12 @@ impl<K: Send + Hash + Eq + Clone + 'static, T: Loader<K>> Requests<K, T> {
|
|||
for key in &keys {
|
||||
res.extend(values.get(key).map(|value| (key.clone(), value.clone())));
|
||||
}
|
||||
tx.send(Ok(res)).ok();
|
||||
tx.0.send(Ok(res)).ok();
|
||||
}
|
||||
}
|
||||
Err(err) => {
|
||||
for (_, tx) in self.pending {
|
||||
tx.send(Err(err.clone())).ok();
|
||||
tx.0.send(Err(err.clone())).ok();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -188,7 +190,7 @@ impl<T> DataLoader<T> {
|
|||
let keys = keys.collect::<HashSet<_>>();
|
||||
typed_requests.keys.extend(keys.clone());
|
||||
let (tx, rx) = oneshot::channel();
|
||||
typed_requests.pending.push((keys, tx));
|
||||
typed_requests.pending.push((keys, ResSender(tx)));
|
||||
if typed_requests.keys.len() >= self.max_batch_size {
|
||||
let r = std::mem::take(&mut *typed_requests);
|
||||
drop(requests);
|
||||
|
|
|
@ -678,22 +678,20 @@ fn visit_input_value<'a, V: Visitor<'a>>(
|
|||
if let Some(expected_ty) = expected_ty {
|
||||
let expected_ty = expected_ty.unwrap_non_null();
|
||||
if let MetaTypeName::Named(expected_ty) = expected_ty {
|
||||
if let Some(ty) = ctx
|
||||
if let Some(MetaType::InputObject { input_fields, .. }) = ctx
|
||||
.registry
|
||||
.types
|
||||
.get(MetaTypeName::concrete_typename(expected_ty))
|
||||
{
|
||||
if let MetaType::InputObject { input_fields, .. } = ty {
|
||||
for (item_key, item_value) in values {
|
||||
if let Some(input_value) = input_fields.get(item_key.as_str()) {
|
||||
visit_input_value(
|
||||
v,
|
||||
ctx,
|
||||
pos,
|
||||
Some(MetaTypeName::create(&input_value.ty)),
|
||||
item_value,
|
||||
);
|
||||
}
|
||||
for (item_key, item_value) in values {
|
||||
if let Some(input_value) = input_fields.get(item_key.as_str()) {
|
||||
visit_input_value(
|
||||
v,
|
||||
ctx,
|
||||
pos,
|
||||
Some(MetaTypeName::create(&input_value.ty)),
|
||||
item_value,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,10 +17,8 @@ impl<'ctx, 'a> Visitor<'ctx> for CacheControlCalculate<'a> {
|
|||
ctx: &mut VisitorContext<'_>,
|
||||
_selection_set: &Positioned<SelectionSet>,
|
||||
) {
|
||||
if let Some(current_type) = ctx.current_type() {
|
||||
if let MetaType::Object { cache_control, .. } = current_type {
|
||||
*self.cache_control = self.cache_control.merge(cache_control);
|
||||
}
|
||||
if let Some(MetaType::Object { cache_control, .. }) = ctx.current_type() {
|
||||
*self.cache_control = self.cache_control.merge(cache_control);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -51,37 +51,33 @@ impl<'ctx, 'a> Visitor<'ctx> for ComplexityCalculate<'ctx, 'a> {
|
|||
fn exit_field(&mut self, ctx: &mut VisitorContext<'ctx>, field: &'ctx Positioned<Field>) {
|
||||
let children_complex = self.complexity_stack.pop().unwrap();
|
||||
|
||||
if let Some(ty) = ctx.parent_type() {
|
||||
if let MetaType::Object { fields, .. } = ty {
|
||||
if let Some(meta_field) = fields.get(MetaTypeName::concrete_typename(
|
||||
field.node.name.node.as_str(),
|
||||
)) {
|
||||
if let Some(compute_complexity) = &meta_field.compute_complexity {
|
||||
match compute_complexity {
|
||||
ComplexityType::Const(n) => {
|
||||
*self.complexity_stack.last_mut().unwrap() += n;
|
||||
}
|
||||
ComplexityType::Fn(f) => {
|
||||
if MetaTypeName::create(&meta_field.ty).is_list() {
|
||||
match f(
|
||||
ctx,
|
||||
self.variable_definition.unwrap(),
|
||||
&field.node,
|
||||
children_complex,
|
||||
) {
|
||||
Ok(n) => {
|
||||
*self.complexity_stack.last_mut().unwrap() += n;
|
||||
}
|
||||
Err(err) => {
|
||||
ctx.report_error(vec![field.pos], err.to_string())
|
||||
}
|
||||
if let Some(MetaType::Object { fields, .. }) = ctx.parent_type() {
|
||||
if let Some(meta_field) = fields.get(MetaTypeName::concrete_typename(
|
||||
field.node.name.node.as_str(),
|
||||
)) {
|
||||
if let Some(compute_complexity) = &meta_field.compute_complexity {
|
||||
match compute_complexity {
|
||||
ComplexityType::Const(n) => {
|
||||
*self.complexity_stack.last_mut().unwrap() += n;
|
||||
}
|
||||
ComplexityType::Fn(f) => {
|
||||
if MetaTypeName::create(&meta_field.ty).is_list() {
|
||||
match f(
|
||||
ctx,
|
||||
self.variable_definition.unwrap(),
|
||||
&field.node,
|
||||
children_complex,
|
||||
) {
|
||||
Ok(n) => {
|
||||
*self.complexity_stack.last_mut().unwrap() += n;
|
||||
}
|
||||
Err(err) => ctx.report_error(vec![field.pos], err.to_string()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user