From 6488bf5ffea3987acc5ba92bd0118404e6a149b5 Mon Sep 17 00:00:00 2001 From: Predrag Gruevski <2348618+obi1kenobi@users.noreply.github.com> Date: Wed, 19 Jul 2023 23:42:12 -0400 Subject: [PATCH] Fix new clippy lints. (#385) --- trustfall_core/src/frontend/mod.rs | 6 +++--- trustfall_core/src/interpreter/execution.rs | 2 +- .../src/interpreter/hints/candidates.rs | 5 +---- .../src/interpreter/hints/tests/mod.rs | 20 +++++++++---------- trustfall_core/src/schema/mod.rs | 20 +++++++++++-------- 5 files changed, 27 insertions(+), 26 deletions(-) diff --git a/trustfall_core/src/frontend/mod.rs b/trustfall_core/src/frontend/mod.rs index ec920c3d..e2bba941 100644 --- a/trustfall_core/src/frontend/mod.rs +++ b/trustfall_core/src/frontend/mod.rs @@ -475,7 +475,7 @@ pub fn make_ir_for_query(schema: &Schema, query: &Query) -> Result post_filters.push(filter), - Err(e) => errors.extend(e.into_iter()), + Err(e) => errors.extend(e), } } for output in &transform_group.output { diff --git a/trustfall_core/src/interpreter/execution.rs b/trustfall_core/src/interpreter/execution.rs index 51f3ce37..3428396f 100644 --- a/trustfall_core/src/interpreter/execution.rs +++ b/trustfall_core/src/interpreter/execution.rs @@ -620,7 +620,7 @@ mismatch on whether the fold below {expanding_from_vid:?} was inside an `@option let prior_folded_values_count = ctx.folded_values.len(); let new_folded_values_count = folded_values.len(); - ctx.folded_values.extend(folded_values.into_iter()); + ctx.folded_values.extend(folded_values); // Ensure the merged maps had disjoint keys. assert_eq!( diff --git a/trustfall_core/src/interpreter/hints/candidates.rs b/trustfall_core/src/interpreter/hints/candidates.rs index 67bc7866..b6de806a 100644 --- a/trustfall_core/src/interpreter/hints/candidates.rs +++ b/trustfall_core/src/interpreter/hints/candidates.rs @@ -783,10 +783,7 @@ mod tests { } } - for (original, intersected) in larger_ranges - .into_iter() - .cartesian_product(smaller_ranges.into_iter()) - { + for (original, intersected) in larger_ranges.into_iter().cartesian_product(smaller_ranges) { let mut expected = intersected.clone(); if let Range(r) = &mut expected { if let Range(r2) = &original { diff --git a/trustfall_core/src/interpreter/hints/tests/mod.rs b/trustfall_core/src/interpreter/hints/tests/mod.rs index 21a19f43..aa742244 100644 --- a/trustfall_core/src/interpreter/hints/tests/mod.rs +++ b/trustfall_core/src/interpreter/hints/tests/mod.rs @@ -1380,7 +1380,7 @@ mod dynamic_property_values { Box::new(value_candidate .expect("no dynamic candidate for 'value' property") .resolve(adapter, ctxs) - .zip_longest(expected_values.into_iter()) + .zip_longest(expected_values) .map(move |data| { if let EitherOrBoth::Both((ctx, value), expected_value) = data { assert_eq!(expected_value, value); @@ -1441,7 +1441,7 @@ mod dynamic_property_values { Box::new(value_candidate .expect("no dynamic candidate for 'value' property") .resolve(adapter, ctxs) - .zip_longest(expected_values.into_iter()) + .zip_longest(expected_values) .map(move |data| { if let EitherOrBoth::Both((ctx, value), expected_value) = data { assert_eq!(expected_value, value); @@ -1539,7 +1539,7 @@ mod dynamic_property_values { Box::new(candidate .expect("no dynamic candidate for 'value' property") .resolve(adapter, ctxs) - .zip_longest(expected_values.into_iter()) + .zip_longest(expected_values) .map(move |data| { if let EitherOrBoth::Both((ctx, value), expected_value) = data { assert_eq!(expected_value, value); @@ -1610,7 +1610,7 @@ mod dynamic_property_values { Box::new(candidate .expect("no dynamic candidate for 'name' property") .resolve(adapter, ctxs) - .zip_longest(expected_values.into_iter()) + .zip_longest(expected_values) .map(move |data| { if let EitherOrBoth::Both((ctx, value), expected_value) = data { assert_eq!(expected_value, value); @@ -1664,7 +1664,7 @@ mod dynamic_property_values { Box::new(candidate .expect("no dynamic candidate for 'value' property") .resolve(adapter, ctxs) - .zip_longest(expected_values.into_iter()) + .zip_longest(expected_values) .map(move |data| { if let EitherOrBoth::Both((ctx, value), expected_value) = data { assert_eq!(expected_value, value); @@ -1805,7 +1805,7 @@ mod dynamic_property_values { Box::new(candidate .expect("no dynamic candidate for 'value' property") .resolve(adapter, ctxs) - .zip_longest(expected_values.into_iter()) + .zip_longest(expected_values) .map(move |data| { if let EitherOrBoth::Both((ctx, value), expected_value) = data { assert_eq!(expected_value, value); @@ -1886,7 +1886,7 @@ mod dynamic_property_values { Box::new(candidate .expect("no dynamic candidate for 'value' property") .resolve(adapter, ctxs) - .zip_longest(expected_values.into_iter()) + .zip_longest(expected_values) .map(move |data| { if let EitherOrBoth::Both((ctx, value), expected_value) = data { assert_eq!(expected_value, value); @@ -1950,7 +1950,7 @@ mod dynamic_property_values { Box::new(candidate .expect("no dynamic candidate for 'value' property") .resolve(adapter, ctxs) - .zip_longest(expected_values.into_iter()) + .zip_longest(expected_values) .map(move |data| { if let EitherOrBoth::Both((ctx, value), expected_value) = data { assert_eq!(expected_value, value); @@ -1974,7 +1974,7 @@ mod dynamic_property_values { Box::new(candidate .expect("no dynamic candidate for 'value' property") .resolve(adapter, ctxs) - .zip_longest(expected_values.into_iter()) + .zip_longest(expected_values) .map(move |data| { if let EitherOrBoth::Both((ctx, value), expected_value) = data { assert_eq!(expected_value, value); @@ -2072,7 +2072,7 @@ mod dynamic_property_values { Box::new(candidate .expect("no dynamic candidate for 'value' property") .resolve(adapter, ctxs) - .zip_longest(expected_values.into_iter()) + .zip_longest(expected_values) .map(move |data| { if let EitherOrBoth::Both((ctx, value), expected_value) = data { assert_eq!(expected_value, value); diff --git a/trustfall_core/src/schema/mod.rs b/trustfall_core/src/schema/mod.rs index 8f329efe..9b9cb15d 100644 --- a/trustfall_core/src/schema/mod.rs +++ b/trustfall_core/src/schema/mod.rs @@ -210,29 +210,29 @@ directive @transform(op: String!) on FIELD let mut errors = vec![]; if let Err(e) = check_required_transitive_implementations(&vertex_types) { - errors.extend(e.into_iter()); + errors.extend(e); } if let Err(e) = check_field_type_narrowing(&vertex_types, &fields) { - errors.extend(e.into_iter()); + errors.extend(e); } if let Err(e) = check_fields_required_by_interface_implementations(&vertex_types, &fields) { - errors.extend(e.into_iter()); + errors.extend(e); } if let Err(e) = check_type_and_property_and_edge_invariants(query_type_definition, &vertex_types) { - errors.extend(e.into_iter()); + errors.extend(e); } if let Err(e) = check_root_query_type_invariants(query_type_definition, &query_type, &vertex_types) { - errors.extend(e.into_iter()); + errors.extend(e); } let field_origins = match get_field_origins(&vertex_types) { Ok(field_origins) => { if let Err(e) = check_ambiguous_field_origins(&fields, &field_origins) { - errors.extend(e.into_iter()); + errors.extend(e); } Some(field_origins) } @@ -599,7 +599,9 @@ fn check_fields_required_by_interface_implementations( for implementation in implementations { let implementation = implementation.node.as_ref(); - let Some(impl_defn) = vertex_types.get(implementation) else { continue; }; + let Some(impl_defn) = vertex_types.get(implementation) else { + continue; + }; for field in get_vertex_type_fields(impl_defn) { let field_name = field.node.name.node.as_ref(); @@ -806,7 +808,9 @@ fn get_field_origins( let mut implemented_fields: BTreeMap<&str, FieldOrigin> = Default::default(); for implemented_interface in implements { let implemented_interface = implemented_interface.node.as_ref(); - let Some(implemented_defn) = vertex_types.get(implemented_interface) else { continue; }; + let Some(implemented_defn) = vertex_types.get(implemented_interface) else { + continue; + }; let parent_fields = get_vertex_type_fields(implemented_defn); for field in parent_fields { let parent_field_origin = &field_origins[&(