Skip to content

Commit

Permalink
fix clippy errors
Browse files Browse the repository at this point in the history
  • Loading branch information
teoxoy committed Oct 5, 2023
1 parent e139963 commit e7c969b
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions src/proc/constant_evaluator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -998,15 +998,15 @@ impl<'a> ConstantEvaluator<'a> {

_ => match (left_value, right_value) {
(Literal::I32(a), Literal::I32(b)) => Literal::I32(match op {
BinaryOperator::Add => a
.checked_add(b)
.ok_or(ConstantEvaluatorError::Overflow("addition".into()))?,
BinaryOperator::Subtract => a
.checked_sub(b)
.ok_or(ConstantEvaluatorError::Overflow("subtraction".into()))?,
BinaryOperator::Multiply => a
.checked_mul(b)
.ok_or(ConstantEvaluatorError::Overflow("multiplication".into()))?,
BinaryOperator::Add => a.checked_add(b).ok_or_else(|| {
ConstantEvaluatorError::Overflow("addition".into())
})?,
BinaryOperator::Subtract => a.checked_sub(b).ok_or_else(|| {
ConstantEvaluatorError::Overflow("subtraction".into())
})?,
BinaryOperator::Multiply => a.checked_mul(b).ok_or_else(|| {
ConstantEvaluatorError::Overflow("multiplication".into())
})?,
BinaryOperator::Divide => a.checked_div(b).ok_or_else(|| {
if b == 0 {
ConstantEvaluatorError::DivisionByZero
Expand Down Expand Up @@ -1036,15 +1036,15 @@ impl<'a> ConstantEvaluator<'a> {
_ => return Err(ConstantEvaluatorError::InvalidBinaryOpArgs),
}),
(Literal::U32(a), Literal::U32(b)) => Literal::U32(match op {
BinaryOperator::Add => a
.checked_add(b)
.ok_or(ConstantEvaluatorError::Overflow("addition".into()))?,
BinaryOperator::Subtract => a
.checked_sub(b)
.ok_or(ConstantEvaluatorError::Overflow("subtraction".into()))?,
BinaryOperator::Multiply => a
.checked_mul(b)
.ok_or(ConstantEvaluatorError::Overflow("multiplication".into()))?,
BinaryOperator::Add => a.checked_add(b).ok_or_else(|| {
ConstantEvaluatorError::Overflow("addition".into())
})?,
BinaryOperator::Subtract => a.checked_sub(b).ok_or_else(|| {
ConstantEvaluatorError::Overflow("subtraction".into())
})?,
BinaryOperator::Multiply => a.checked_mul(b).ok_or_else(|| {
ConstantEvaluatorError::Overflow("multiplication".into())
})?,
BinaryOperator::Divide => a
.checked_div(b)
.ok_or(ConstantEvaluatorError::DivisionByZero)?,
Expand Down

0 comments on commit e7c969b

Please sign in to comment.