From 3fae807d9ff5a988d8df7367bcc0430190938eeb Mon Sep 17 00:00:00 2001 From: Jeff Date: Fri, 2 Aug 2024 15:21:15 -0400 Subject: [PATCH] Clean up with clippy --- dust-lang/src/abstract_tree/logic.rs | 22 +++++++++++----------- dust-lang/src/abstract_tree/value_node.rs | 3 +-- dust-lang/src/parser/mod.rs | 2 +- dust-lang/src/parser/tests.rs | 4 ++-- dust-lang/src/value.rs | 2 +- 5 files changed, 16 insertions(+), 17 deletions(-) diff --git a/dust-lang/src/abstract_tree/logic.rs b/dust-lang/src/abstract_tree/logic.rs index c103d25..ce1008a 100644 --- a/dust-lang/src/abstract_tree/logic.rs +++ b/dust-lang/src/abstract_tree/logic.rs @@ -258,7 +258,7 @@ mod tests { Expression::Value(ValueNode::Integer(42).with_position((0, 0))), Expression::Value(ValueNode::Integer(42).with_position((0, 0))) ) - .evaluate(&mut Context::new(), true, SourcePosition(0, 0)), + .evaluate(&Context::new(), true, SourcePosition(0, 0)), Ok(Some(Evaluation::Return(Value::boolean(true)))) ) } @@ -270,7 +270,7 @@ mod tests { Expression::Value(ValueNode::Integer(42).with_position((0, 0))), Expression::Value(ValueNode::Integer(43).with_position((0, 0))) ) - .evaluate(&mut Context::new(), true, SourcePosition(0, 0)), + .evaluate(&Context::new(), true, SourcePosition(0, 0)), Ok(Some(Evaluation::Return(Value::boolean(true)))) ) } @@ -282,7 +282,7 @@ mod tests { Expression::Value(ValueNode::Integer(43).with_position((0, 0))), Expression::Value(ValueNode::Integer(42).with_position((0, 0))) ) - .evaluate(&mut Context::new(), true, SourcePosition(0, 0)), + .evaluate(&Context::new(), true, SourcePosition(0, 0)), Ok(Some(Evaluation::Return(Value::boolean(true)))) ) } @@ -294,7 +294,7 @@ mod tests { Expression::Value(ValueNode::Integer(42).with_position((0, 0))), Expression::Value(ValueNode::Integer(43).with_position((0, 0))) ) - .evaluate(&mut Context::new(), true, SourcePosition(0, 0)), + .evaluate(&Context::new(), true, SourcePosition(0, 0)), Ok(Some(Evaluation::Return(Value::boolean(true)))) ) } @@ -306,7 +306,7 @@ mod tests { Expression::Value(ValueNode::Integer(42).with_position((0, 0))), Expression::Value(ValueNode::Integer(41).with_position((0, 0))) ) - .evaluate(&mut Context::new(), true, SourcePosition(0, 0)), + .evaluate(&Context::new(), true, SourcePosition(0, 0)), Ok(Some(Evaluation::Return(Value::boolean(true)))) ); @@ -315,7 +315,7 @@ mod tests { Expression::Value(ValueNode::Integer(42).with_position((0, 0))), Expression::Value(ValueNode::Integer(42).with_position((0, 0))), ) - .evaluate(&mut Context::new(), true, SourcePosition(0, 0)), + .evaluate(&Context::new(), true, SourcePosition(0, 0)), Ok(Some(Evaluation::Return(Value::boolean(true)))) ); } @@ -327,7 +327,7 @@ mod tests { Expression::Value(ValueNode::Integer(41).with_position((0, 0))), Expression::Value(ValueNode::Integer(42).with_position((0, 0))), ) - .evaluate(&mut Context::new(), true, SourcePosition(0, 0)), + .evaluate(&Context::new(), true, SourcePosition(0, 0)), Ok(Some(Evaluation::Return(Value::boolean(true)))) ); @@ -336,7 +336,7 @@ mod tests { Expression::Value(ValueNode::Integer(42).with_position((0, 0))), Expression::Value(ValueNode::Integer(42).with_position((0, 0))), ) - .evaluate(&mut Context::new(), true, SourcePosition(0, 0)), + .evaluate(&Context::new(), true, SourcePosition(0, 0)), Ok(Some(Evaluation::Return(Value::boolean(true)))) ); } @@ -348,7 +348,7 @@ mod tests { Expression::Value(ValueNode::Boolean(true).with_position((0, 0))), Expression::Value(ValueNode::Boolean(true).with_position((0, 0))), ) - .evaluate(&mut Context::new(), true, SourcePosition(0, 0)), + .evaluate(&Context::new(), true, SourcePosition(0, 0)), Ok(Some(Evaluation::Return(Value::boolean(true)))) ) } @@ -360,7 +360,7 @@ mod tests { Expression::Value(ValueNode::Boolean(true).with_position((0, 0))), Expression::Value(ValueNode::Boolean(false).with_position((0, 0))), ) - .evaluate(&mut Context::new(), true, SourcePosition(0, 0)), + .evaluate(&Context::new(), true, SourcePosition(0, 0)), Ok(Some(Evaluation::Return(Value::boolean(true)))) ) } @@ -371,7 +371,7 @@ mod tests { Logic::Not(Expression::Value( ValueNode::Boolean(false).with_position((0, 0)) )) - .evaluate(&mut Context::new(), true, SourcePosition(0, 0)), + .evaluate(&Context::new(), true, SourcePosition(0, 0)), Ok(Some(Evaluation::Return(Value::boolean(true)))) ) } diff --git a/dust-lang/src/abstract_tree/value_node.rs b/dust-lang/src/abstract_tree/value_node.rs index a5e17a8..59a04de 100644 --- a/dust-lang/src/abstract_tree/value_node.rs +++ b/dust-lang/src/abstract_tree/value_node.rs @@ -128,8 +128,7 @@ impl AbstractNode for ValueNode { let found = variants .into_iter() - .find(|(identifier, _)| identifier == &variant.node) - .is_some(); + .any(|(identifier, _)| identifier == variant.node); if !found { return Err(ValidationError::EnumVariantNotFound { diff --git a/dust-lang/src/parser/mod.rs b/dust-lang/src/parser/mod.rs index b8cd75f..7155117 100644 --- a/dust-lang/src/parser/mod.rs +++ b/dust-lang/src/parser/mod.rs @@ -345,7 +345,7 @@ pub fn parser<'src>( type_name, type_arguments, variant, - content: content.map(|expression| Box::new(expression)), + content: content.map(Box::new), } .with_position(state.span()), ) diff --git a/dust-lang/src/parser/tests.rs b/dust-lang/src/parser/tests.rs index 9103cbb..5d993fc 100644 --- a/dust-lang/src/parser/tests.rs +++ b/dust-lang/src/parser/tests.rs @@ -286,7 +286,7 @@ fn built_in_function() { .map_err(|errors| { errors .into_iter() - .map(|error| DustError::from(error)) + .map(DustError::from) .collect::>() }) .unwrap(); @@ -308,7 +308,7 @@ fn built_in_function_with_arg() { .map_err(|errors| { errors .into_iter() - .map(|error| DustError::from(error)) + .map(DustError::from) .collect::>() }) .unwrap(); diff --git a/dust-lang/src/value.rs b/dust-lang/src/value.rs index e08831d..3dcfc67 100644 --- a/dust-lang/src/value.rs +++ b/dust-lang/src/value.rs @@ -649,7 +649,7 @@ impl ValueInner { } } ValueInner::Structure { name, .. } => { - if let Some(r#type) = context.get_type(&name)? { + if let Some(r#type) = context.get_type(name)? { r#type } else { return Err(ValidationError::StructDefinitionNotFound {