From 7745710dc40b55c516b14027938e427b3c76aa5d Mon Sep 17 00:00:00 2001 From: collin Date: Fri, 4 Dec 2020 19:06:29 -0500 Subject: [PATCH] cargo +nightly clippy --- compiler/src/errors/statement.rs | 4 ++-- compiler/src/function/function.rs | 2 +- compiler/src/function/result/result.rs | 6 +++++- compiler/src/statement/statement.rs | 2 +- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/compiler/src/errors/statement.rs b/compiler/src/errors/statement.rs index 4fd0dc7d5e..b1e7cf908d 100644 --- a/compiler/src/errors/statement.rs +++ b/compiler/src/errors/statement.rs @@ -136,8 +136,8 @@ impl StatementError { } pub fn multiple_returns(span: Span) -> Self { - let message = - format!("This function returns multiple times and produces unreachable circuits with undefined behavior."); + let message = "This function returns multiple times and produces unreachable circuits with undefined behavior." + .to_string(); Self::new_from_span(message, span) } diff --git a/compiler/src/function/function.rs b/compiler/src/function/function.rs index 53ac0a82ba..d1f1d96f1d 100644 --- a/compiler/src/function/function.rs +++ b/compiler/src/function/function.rs @@ -111,6 +111,6 @@ impl> ConstrainedProgram { // Conditionally select a result based on returned indicators Self::conditionally_select_result(cs, function.output, results, &function.span) - .map_err(|err| FunctionError::StatementError(err)) + .map_err(FunctionError::StatementError) } } diff --git a/compiler/src/function/result/result.rs b/compiler/src/function/result/result.rs index f8fae3bb17..1971dd7c4e 100644 --- a/compiler/src/function/result/result.rs +++ b/compiler/src/function/result/result.rs @@ -67,7 +67,11 @@ impl> ConstrainedProgram { }; // 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())); } diff --git a/compiler/src/statement/statement.rs b/compiler/src/statement/statement.rs index 61ad80c87a..6e96c88c9a 100644 --- a/compiler/src/statement/statement.rs +++ b/compiler/src/statement/statement.rs @@ -124,7 +124,7 @@ impl> ConstrainedProgram { match &value { ConstrainedValue::Tuple(values) => { if !values.is_empty() { - results.push((indicator.clone(), value)); + results.push((*indicator, value)); } } _ => return Err(StatementError::unassigned(expression_string, span)),