cargo +nightly clippy

This commit is contained in:
collin 2020-12-04 19:06:29 -05:00
parent cd53cba77a
commit 7745710dc4
4 changed files with 9 additions and 5 deletions

View File

@ -136,8 +136,8 @@ impl StatementError {
} }
pub fn multiple_returns(span: Span) -> Self { pub fn multiple_returns(span: Span) -> Self {
let message = let message = "This function returns multiple times and produces unreachable circuits with undefined behavior."
format!("This function returns multiple times and produces unreachable circuits with undefined behavior."); .to_string();
Self::new_from_span(message, span) Self::new_from_span(message, span)
} }

View File

@ -111,6 +111,6 @@ impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
// Conditionally select a result based on returned indicators // Conditionally select a result based on returned indicators
Self::conditionally_select_result(cs, function.output, results, &function.span) Self::conditionally_select_result(cs, function.output, results, &function.span)
.map_err(|err| FunctionError::StatementError(err)) .map_err(FunctionError::StatementError)
} }
} }

View File

@ -67,7 +67,11 @@ impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
}; };
// Error if the function or one of its branches does not return. // Error if the function or one of its branches does not return.
if let None = results.iter().find(|(indicator, _res)| get_indicator_value(indicator)) { if results
.iter()
.find(|(indicator, _res)| get_indicator_value(indicator))
.is_none()
{
return Err(StatementError::no_returns(return_type, span.to_owned())); return Err(StatementError::no_returns(return_type, span.to_owned()));
} }

View File

@ -124,7 +124,7 @@ impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
match &value { match &value {
ConstrainedValue::Tuple(values) => { ConstrainedValue::Tuple(values) => {
if !values.is_empty() { if !values.is_empty() {
results.push((indicator.clone(), value)); results.push((*indicator, value));
} }
} }
_ => return Err(StatementError::unassigned(expression_string, span)), _ => return Err(StatementError::unassigned(expression_string, span)),