mirror of
https://github.com/ProvableHQ/leo.git
synced 2024-12-26 03:33:44 +03:00
clippy: fix redundant_clone & clone_on_copy
Signed-off-by: ljedrz <ljedrz@gmail.com>
This commit is contained in:
parent
93369aed33
commit
1fc9b902dd
@ -53,7 +53,7 @@ impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
// Unwrap assertion value and handle errors
|
||||
let result_option = match assert_expression {
|
||||
ConstrainedValue::Boolean(boolean) => boolean.get_value(),
|
||||
_ => return Err(ConsoleError::assertion_must_be_boolean(expression_string, span.clone())),
|
||||
_ => return Err(ConsoleError::assertion_must_be_boolean(expression_string, span)),
|
||||
};
|
||||
let result_bool = result_option.ok_or(ConsoleError::assertion_depends_on_input(span.clone()))?;
|
||||
|
||||
|
@ -37,7 +37,7 @@ impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
return Err(ConsoleError::length(
|
||||
formatted.containers.len(),
|
||||
formatted.parameters.len(),
|
||||
formatted.span.clone(),
|
||||
formatted.span,
|
||||
));
|
||||
}
|
||||
|
||||
|
@ -57,7 +57,7 @@ impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
};
|
||||
let to_resolved = match to {
|
||||
Some(to_index) => {
|
||||
self.enforce_index(cs, file_scope.clone(), function_scope.clone(), to_index, span.clone())?
|
||||
self.enforce_index(cs, file_scope, function_scope, to_index, span)?
|
||||
}
|
||||
None => array.len(), // Array slice ends at array length
|
||||
};
|
||||
|
@ -47,12 +47,12 @@ impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
match type_ {
|
||||
Type::Array(ref type_, ref dimensions) => {
|
||||
let number = match dimensions.first() {
|
||||
Some(number) => number.clone(),
|
||||
Some(number) => *number,
|
||||
None => return Err(ExpressionError::unexpected_array(type_.to_string(), span)),
|
||||
};
|
||||
|
||||
expected_dimensions.push(number);
|
||||
expected_type = Some(type_.outer_dimension(dimensions).clone());
|
||||
expected_type = Some(type_.outer_dimension(dimensions));
|
||||
}
|
||||
ref type_ => {
|
||||
return Err(ExpressionError::unexpected_array(type_.to_string(), span));
|
||||
|
@ -36,13 +36,13 @@ impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
let expected_type = Some(Type::IntegerType(IntegerType::U32));
|
||||
match self.enforce_operand(
|
||||
cs,
|
||||
file_scope.clone(),
|
||||
function_scope.clone(),
|
||||
file_scope,
|
||||
function_scope,
|
||||
expected_type,
|
||||
index,
|
||||
span.clone(),
|
||||
)? {
|
||||
ConstrainedValue::Integer(number) => Ok(number.to_usize(span.clone())?),
|
||||
ConstrainedValue::Integer(number) => Ok(number.to_usize(span)?),
|
||||
value => Err(ExpressionError::invalid_index(value.to_string(), span)),
|
||||
}
|
||||
}
|
||||
|
@ -45,8 +45,8 @@ impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
)?;
|
||||
let mut resolved_right = self.enforce_operand(
|
||||
cs,
|
||||
file_scope.clone(),
|
||||
function_scope.clone(),
|
||||
file_scope,
|
||||
function_scope,
|
||||
expected_type.clone(),
|
||||
right,
|
||||
span.clone(),
|
||||
|
@ -45,11 +45,11 @@ impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
// access a circuit member using the `self` keyword
|
||||
if let Expression::Identifier(ref identifier) = *circuit_identifier {
|
||||
if identifier.is_self() {
|
||||
let self_file_scope = new_scope(file_scope.clone(), identifier.name.to_string());
|
||||
let self_file_scope = new_scope(file_scope, identifier.name.to_string());
|
||||
let self_function_scope = new_scope(self_file_scope.clone(), identifier.name.to_string());
|
||||
|
||||
let member_value =
|
||||
self.evaluate_identifier(self_file_scope, self_function_scope, None, circuit_member.clone())?;
|
||||
self.evaluate_identifier(self_file_scope, self_function_scope, None, circuit_member)?;
|
||||
|
||||
return Ok(member_value);
|
||||
}
|
||||
@ -58,9 +58,9 @@ impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
let (circuit_name, members) = match self.enforce_operand(
|
||||
cs,
|
||||
file_scope.clone(),
|
||||
function_scope.clone(),
|
||||
function_scope,
|
||||
expected_type,
|
||||
*circuit_identifier.clone(),
|
||||
*circuit_identifier,
|
||||
span.clone(),
|
||||
)? {
|
||||
ConstrainedValue::CircuitExpression(name, members) => (name, members),
|
||||
|
@ -55,7 +55,7 @@ impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
let circuit_identifier = circuit.circuit_name.clone();
|
||||
let mut resolved_members = vec![];
|
||||
|
||||
for member in circuit.members.clone().into_iter() {
|
||||
for member in circuit.members.into_iter() {
|
||||
match member {
|
||||
CircuitMember::CircuitVariable(is_mutable, identifier, type_) => {
|
||||
let matched_variable = members
|
||||
@ -98,7 +98,7 @@ impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
}
|
||||
|
||||
Ok(ConstrainedValue::CircuitExpression(
|
||||
circuit_identifier.clone(),
|
||||
circuit_identifier,
|
||||
resolved_members,
|
||||
))
|
||||
}
|
||||
|
@ -36,23 +36,23 @@ impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
span: Span,
|
||||
) -> Result<ConstrainedValue<F, G>, ExpressionError> {
|
||||
// Get defined circuit
|
||||
let circuit = match *circuit_identifier.clone() {
|
||||
let circuit = match *circuit_identifier {
|
||||
Expression::Identifier(identifier) => {
|
||||
// Use the "Self" keyword to access a static circuit function
|
||||
if identifier.is_self() {
|
||||
let circuit = self
|
||||
.get(&file_scope)
|
||||
.ok_or(ExpressionError::self_keyword(identifier.span.clone()))?;
|
||||
.ok_or(ExpressionError::self_keyword(identifier.span))?;
|
||||
|
||||
circuit.to_owned()
|
||||
} else {
|
||||
self.evaluate_identifier(file_scope.clone(), function_scope.clone(), expected_type, identifier)?
|
||||
self.evaluate_identifier(file_scope, function_scope, expected_type, identifier)?
|
||||
}
|
||||
}
|
||||
expression => self.enforce_expression(
|
||||
cs,
|
||||
file_scope.clone(),
|
||||
function_scope.clone(),
|
||||
file_scope,
|
||||
function_scope,
|
||||
expected_type,
|
||||
expression,
|
||||
)?,
|
||||
|
@ -59,8 +59,8 @@ impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
|
||||
let second_value = self.enforce_operand(
|
||||
cs,
|
||||
file_scope.clone(),
|
||||
function_scope.clone(),
|
||||
file_scope,
|
||||
function_scope,
|
||||
expected_type,
|
||||
second,
|
||||
span.clone(),
|
||||
|
@ -70,8 +70,8 @@ impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
Expression::Add(left, right, span) => {
|
||||
let (resolved_left, resolved_right) = self.enforce_binary_expression(
|
||||
cs,
|
||||
file_scope.clone(),
|
||||
function_scope.clone(),
|
||||
file_scope,
|
||||
function_scope,
|
||||
expected_type,
|
||||
*left,
|
||||
*right,
|
||||
@ -83,8 +83,8 @@ impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
Expression::Sub(left, right, span) => {
|
||||
let (resolved_left, resolved_right) = self.enforce_binary_expression(
|
||||
cs,
|
||||
file_scope.clone(),
|
||||
function_scope.clone(),
|
||||
file_scope,
|
||||
function_scope,
|
||||
expected_type,
|
||||
*left,
|
||||
*right,
|
||||
@ -96,8 +96,8 @@ impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
Expression::Mul(left, right, span) => {
|
||||
let (resolved_left, resolved_right) = self.enforce_binary_expression(
|
||||
cs,
|
||||
file_scope.clone(),
|
||||
function_scope.clone(),
|
||||
file_scope,
|
||||
function_scope,
|
||||
expected_type,
|
||||
*left,
|
||||
*right,
|
||||
@ -109,8 +109,8 @@ impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
Expression::Div(left, right, span) => {
|
||||
let (resolved_left, resolved_right) = self.enforce_binary_expression(
|
||||
cs,
|
||||
file_scope.clone(),
|
||||
function_scope.clone(),
|
||||
file_scope,
|
||||
function_scope,
|
||||
expected_type,
|
||||
*left,
|
||||
*right,
|
||||
@ -122,8 +122,8 @@ impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
Expression::Pow(left, right, span) => {
|
||||
let (resolved_left, resolved_right) = self.enforce_binary_expression(
|
||||
cs,
|
||||
file_scope.clone(),
|
||||
function_scope.clone(),
|
||||
file_scope,
|
||||
function_scope,
|
||||
expected_type,
|
||||
*left,
|
||||
*right,
|
||||
@ -141,8 +141,8 @@ impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
Expression::Or(left, right, span) => {
|
||||
let (resolved_left, resolved_right) = self.enforce_binary_expression(
|
||||
cs,
|
||||
file_scope.clone(),
|
||||
function_scope.clone(),
|
||||
file_scope,
|
||||
function_scope,
|
||||
expected_type,
|
||||
*left,
|
||||
*right,
|
||||
@ -154,8 +154,8 @@ impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
Expression::And(left, right, span) => {
|
||||
let (resolved_left, resolved_right) = self.enforce_binary_expression(
|
||||
cs,
|
||||
file_scope.clone(),
|
||||
function_scope.clone(),
|
||||
file_scope,
|
||||
function_scope,
|
||||
expected_type,
|
||||
*left,
|
||||
*right,
|
||||
@ -167,8 +167,8 @@ impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
Expression::Eq(left, right, span) => {
|
||||
let (resolved_left, resolved_right) = self.enforce_binary_expression(
|
||||
cs,
|
||||
file_scope.clone(),
|
||||
function_scope.clone(),
|
||||
file_scope,
|
||||
function_scope,
|
||||
None,
|
||||
*left,
|
||||
*right,
|
||||
@ -180,8 +180,8 @@ impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
Expression::Ge(left, right, span) => {
|
||||
let (resolved_left, resolved_right) = self.enforce_binary_expression(
|
||||
cs,
|
||||
file_scope.clone(),
|
||||
function_scope.clone(),
|
||||
file_scope,
|
||||
function_scope,
|
||||
None,
|
||||
*left,
|
||||
*right,
|
||||
@ -193,8 +193,8 @@ impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
Expression::Gt(left, right, span) => {
|
||||
let (resolved_left, resolved_right) = self.enforce_binary_expression(
|
||||
cs,
|
||||
file_scope.clone(),
|
||||
function_scope.clone(),
|
||||
file_scope,
|
||||
function_scope,
|
||||
None,
|
||||
*left,
|
||||
*right,
|
||||
@ -206,8 +206,8 @@ impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
Expression::Le(left, right, span) => {
|
||||
let (resolved_left, resolved_right) = self.enforce_binary_expression(
|
||||
cs,
|
||||
file_scope.clone(),
|
||||
function_scope.clone(),
|
||||
file_scope,
|
||||
function_scope,
|
||||
None,
|
||||
*left,
|
||||
*right,
|
||||
@ -219,8 +219,8 @@ impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
Expression::Lt(left, right, span) => {
|
||||
let (resolved_left, resolved_right) = self.enforce_binary_expression(
|
||||
cs,
|
||||
file_scope.clone(),
|
||||
function_scope.clone(),
|
||||
file_scope,
|
||||
function_scope,
|
||||
None,
|
||||
*left,
|
||||
*right,
|
||||
|
@ -35,7 +35,7 @@ impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
arguments: Vec<Expression>,
|
||||
span: Span,
|
||||
) -> Result<ConstrainedValue<F, G>, ExpressionError> {
|
||||
let (declared_circuit_reference, function_value) = match *function.clone() {
|
||||
let (declared_circuit_reference, function_value) = match *function {
|
||||
Expression::CircuitMemberAccess(circuit_identifier, circuit_member, span) => {
|
||||
// Call a circuit function that can mutate self.
|
||||
|
||||
@ -62,7 +62,7 @@ impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
),
|
||||
};
|
||||
|
||||
let (outer_scope, function_call) = function_value.extract_function(file_scope.clone(), span.clone())?;
|
||||
let (outer_scope, function_call) = function_value.extract_function(file_scope, span.clone())?;
|
||||
|
||||
let name_unique = format!(
|
||||
"function call {} {}:{}",
|
||||
|
@ -37,7 +37,7 @@ impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
unresolved_identifier: Identifier,
|
||||
) -> Result<ConstrainedValue<F, G>, ExpressionError> {
|
||||
// Evaluate the identifier name in the current function scope
|
||||
let variable_name = new_scope(function_scope.clone(), unresolved_identifier.to_string());
|
||||
let variable_name = new_scope(function_scope, unresolved_identifier.to_string());
|
||||
let identifier_name = new_scope(file_scope, unresolved_identifier.to_string());
|
||||
|
||||
let mut result_value = if let Some(value) = self.get(&variable_name) {
|
||||
@ -58,7 +58,7 @@ impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
return Err(ExpressionError::undefined_identifier(unresolved_identifier));
|
||||
};
|
||||
|
||||
result_value.resolve_type(expected_type, unresolved_identifier.span.clone())?;
|
||||
result_value.resolve_type(expected_type, unresolved_identifier.span)?;
|
||||
|
||||
Ok(result_value)
|
||||
}
|
||||
|
@ -37,14 +37,14 @@ impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
) -> Result<ConstrainedValue<F, G>, ExpressionError> {
|
||||
let tuple = match self.enforce_operand(
|
||||
cs,
|
||||
file_scope.clone(),
|
||||
function_scope.clone(),
|
||||
file_scope,
|
||||
function_scope,
|
||||
expected_type,
|
||||
*tuple,
|
||||
span.clone(),
|
||||
)? {
|
||||
ConstrainedValue::Tuple(tuple) => tuple,
|
||||
value => return Err(ExpressionError::undefined_array(value.to_string(), span.clone())),
|
||||
value => return Err(ExpressionError::undefined_array(value.to_string(), span)),
|
||||
};
|
||||
|
||||
if index > tuple.len() - 1 {
|
||||
|
@ -55,7 +55,7 @@ impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
check_arguments_length(function.input.len(), input.len(), function.span.clone())?;
|
||||
|
||||
// Store input values as new variables in resolved program
|
||||
for (input_model, input_expression) in function.input.clone().iter().zip(input.into_iter()) {
|
||||
for (input_model, input_expression) in function.input.iter().zip(input.into_iter()) {
|
||||
let (name, value) = match input_model {
|
||||
InputVariable::InputKeyword(identifier) => {
|
||||
let input_value = self.enforce_function_input(
|
||||
|
@ -30,11 +30,10 @@ fn parse_import_file(entry: &DirEntry, span: &Span) -> Result<Program, ImportErr
|
||||
.map_err(|error| ImportError::directory_error(error, span.clone(), entry.path()))?;
|
||||
let file_name = entry
|
||||
.file_name()
|
||||
.to_os_string()
|
||||
.into_string()
|
||||
.map_err(|_| ImportError::convert_os_string(span.clone()))?;
|
||||
|
||||
let mut file_path = entry.path().to_path_buf();
|
||||
let mut file_path = entry.path();
|
||||
if file_type.is_dir() {
|
||||
file_path.push(LIBRARY_FILE);
|
||||
|
||||
@ -62,7 +61,7 @@ impl ImportParser {
|
||||
.extension()
|
||||
.map_or(false, |ext| ext.eq(&OsString::from(FILE_EXTENSION)));
|
||||
|
||||
let mut package_path = path.to_path_buf();
|
||||
let mut package_path = path;
|
||||
package_path.push(LIBRARY_FILE);
|
||||
|
||||
let is_package = is_dir && package_path.exists();
|
||||
@ -93,7 +92,7 @@ impl ImportParser {
|
||||
Ok(())
|
||||
} else {
|
||||
// importing * from a directory or non-leo file in `package/src/` is illegal
|
||||
Err(ImportError::star(entry.path().to_path_buf(), span.clone()))
|
||||
Err(ImportError::star(entry.path(), span.clone()))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@ impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
.find(|package| import.package.eq(package));
|
||||
|
||||
if let Some(package) = core_dependency {
|
||||
self.store_core_package(scope.clone(), package.clone())?;
|
||||
self.store_core_package(scope, package.clone())?;
|
||||
|
||||
return Ok(());
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
|
||||
let value = match matched_circuit {
|
||||
Some((_circuit_name, circuit)) => ConstrainedValue::Import(
|
||||
program_name.clone(),
|
||||
program_name,
|
||||
Box::new(ConstrainedValue::CircuitDefinition(circuit.clone())),
|
||||
),
|
||||
None => {
|
||||
@ -71,7 +71,7 @@ impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
|
||||
match matched_function {
|
||||
Some((_function_name, function)) => ConstrainedValue::Import(
|
||||
program_name.clone(),
|
||||
program_name,
|
||||
Box::new(ConstrainedValue::Function(None, function.clone())),
|
||||
),
|
||||
None => return Err(ImportError::unknown_symbol(symbol.to_owned(), program_name)),
|
||||
|
@ -44,7 +44,7 @@ impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
// Resolve index so we know if we are assigning to a single value or a range of values
|
||||
match range_or_expression {
|
||||
RangeOrExpression::Expression(index) => {
|
||||
let index = self.enforce_index(cs, file_scope.clone(), function_scope.clone(), index, span.clone())?;
|
||||
let index = self.enforce_index(cs, file_scope, function_scope, index, span.clone())?;
|
||||
|
||||
// Modify the single value of the array in place
|
||||
match self.get_mutable_assignee(name, span.clone())? {
|
||||
@ -77,8 +77,8 @@ impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
let to_index_option = match to {
|
||||
Some(integer) => Some(self.enforce_index(
|
||||
cs,
|
||||
file_scope.clone(),
|
||||
function_scope.clone(),
|
||||
file_scope,
|
||||
function_scope,
|
||||
integer,
|
||||
span.clone(),
|
||||
)?),
|
||||
|
@ -57,7 +57,7 @@ impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
match assignee {
|
||||
Assignee::Identifier(_identifier) => {
|
||||
let condition = indicator.unwrap_or(Boolean::Constant(true));
|
||||
let old_value = self.get_mutable_assignee(variable_name.clone(), span.clone())?;
|
||||
let old_value = self.get_mutable_assignee(variable_name, span.clone())?;
|
||||
|
||||
new_value.resolve_type(Some(old_value.to_type(span.clone())?), span.clone())?;
|
||||
|
||||
|
@ -81,7 +81,7 @@ impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
|
||||
member.1 = selected_value.to_owned();
|
||||
|
||||
Ok(selected_value.to_owned())
|
||||
Ok(selected_value)
|
||||
}
|
||||
_ => {
|
||||
// Throw an error if we try to mutate an immutable circuit variable
|
||||
|
@ -41,7 +41,7 @@ impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
cs,
|
||||
file_scope.clone(),
|
||||
function_scope.clone(),
|
||||
indicator.clone(),
|
||||
indicator,
|
||||
statement.clone(),
|
||||
return_type.clone(),
|
||||
"".to_owned(),
|
||||
|
@ -56,7 +56,7 @@ impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
) -> Result<Vec<ConstrainedValue<F, G>>, StatementError> {
|
||||
let types = match type_ {
|
||||
Some(Type::Tuple(types)) => types,
|
||||
Some(type_) => return Err(StatementError::tuple_type(type_.to_string(), span.clone())),
|
||||
Some(type_) => return Err(StatementError::tuple_type(type_.to_string(), span)),
|
||||
None => vec![],
|
||||
};
|
||||
|
||||
@ -157,7 +157,7 @@ impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
let variable = variables.names[0].clone();
|
||||
let expression = self.enforce_expression(
|
||||
cs,
|
||||
file_scope.clone(),
|
||||
file_scope,
|
||||
function_scope.clone(),
|
||||
variables.type_,
|
||||
expressions[0].clone(),
|
||||
@ -181,14 +181,14 @@ impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
|
||||
let values = match self.enforce_expression(
|
||||
cs,
|
||||
file_scope.clone(),
|
||||
file_scope,
|
||||
function_scope.clone(),
|
||||
variables.type_.clone(),
|
||||
expressions[0].clone(),
|
||||
)? {
|
||||
// ConstrainedValue::Return(values) => values,
|
||||
ConstrainedValue::Tuple(values) => values,
|
||||
value => return Err(StatementError::multiple_definition(value.to_string(), span.clone())),
|
||||
value => return Err(StatementError::multiple_definition(value.to_string(), span)),
|
||||
};
|
||||
|
||||
self.enforce_multiple_definition(cs, function_scope, is_constant, variables, values, span)
|
||||
|
@ -56,8 +56,8 @@ impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
|
||||
let result = self.enforce_operand(
|
||||
cs,
|
||||
file_scope.clone(),
|
||||
function_scope.clone(),
|
||||
file_scope,
|
||||
function_scope,
|
||||
return_type.clone(),
|
||||
expression,
|
||||
span.clone(),
|
||||
|
@ -205,7 +205,7 @@ impl EdwardsGroupType {
|
||||
// Sign inferred
|
||||
None => {
|
||||
// Attempt to recover with a sign_low bit.
|
||||
if let Some(element) = EdwardsAffine::from_x_coordinate(x.clone(), false) {
|
||||
if let Some(element) = EdwardsAffine::from_x_coordinate(x, false) {
|
||||
return Ok(element);
|
||||
}
|
||||
|
||||
@ -234,7 +234,7 @@ impl EdwardsGroupType {
|
||||
// Sign inferred
|
||||
None => {
|
||||
// Attempt to recover with a sign_low bit.
|
||||
if let Some(element) = EdwardsAffine::from_y_coordinate(y.clone(), false) {
|
||||
if let Some(element) = EdwardsAffine::from_y_coordinate(y, false) {
|
||||
return Ok(element);
|
||||
}
|
||||
|
||||
|
@ -110,7 +110,7 @@ impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedValue<F, G> {
|
||||
|
||||
// Data type wrappers
|
||||
ConstrainedValue::Array(array) => {
|
||||
let array_type = array[0].to_type(span.clone())?;
|
||||
let array_type = array[0].to_type(span)?;
|
||||
let mut dimensions = vec![array.len()];
|
||||
|
||||
// Nested array type
|
||||
@ -205,12 +205,12 @@ impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedValue<F, G> {
|
||||
// If this is a circuit function, evaluate inside the circuit scope
|
||||
if let Some(identifier) = circuit_identifier {
|
||||
// avoid creating recursive scope
|
||||
if !is_in_scope(&scope, &identifier.name.to_string()) {
|
||||
outer_scope = new_scope(scope, identifier.name.to_string());
|
||||
if !is_in_scope(&scope, &identifier.name) {
|
||||
outer_scope = new_scope(scope, identifier.name);
|
||||
}
|
||||
}
|
||||
|
||||
Ok((outer_scope, function.clone()))
|
||||
Ok((outer_scope, function))
|
||||
}
|
||||
ConstrainedValue::Import(import_scope, function) => function.extract_function(import_scope, span),
|
||||
value => Err(ExpressionError::undefined_function(value.to_string(), span)),
|
||||
|
@ -104,7 +104,7 @@ impl CoreCircuit for Blake2sCircuit {
|
||||
),
|
||||
span.clone(),
|
||||
)],
|
||||
span: span.clone(),
|
||||
span,
|
||||
},
|
||||
)],
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ impl SignExtend for Boolean {
|
||||
fn sign_extend(bits: &[Boolean], length: usize) -> Vec<Boolean> {
|
||||
let msb = bits.last().expect("empty bit list");
|
||||
let bits_needed = length - bits.len();
|
||||
let mut extension = vec![msb.clone(); bits_needed];
|
||||
let mut extension = vec![*msb; bits_needed];
|
||||
|
||||
let mut result = Vec::from(bits);
|
||||
result.append(&mut extension);
|
||||
|
@ -93,7 +93,7 @@ impl CLI for BuildCommand {
|
||||
// Compile the library file but do not output
|
||||
let _program = Compiler::<Fq, EdwardsGroupType>::parse_program_without_input(
|
||||
package_name.clone(),
|
||||
lib_file_path.clone(),
|
||||
lib_file_path,
|
||||
output_directory.clone(),
|
||||
)?;
|
||||
tracing::info!("Complete");
|
||||
@ -121,7 +121,7 @@ impl CLI for BuildCommand {
|
||||
// Load the program at `main_file_path`
|
||||
let program = Compiler::<Fq, EdwardsGroupType>::parse_program_with_input(
|
||||
package_name.clone(),
|
||||
main_file_path.clone(),
|
||||
main_file_path,
|
||||
output_directory,
|
||||
&input_string,
|
||||
input_path,
|
||||
|
@ -65,7 +65,7 @@ impl CLI for DeployCommand {
|
||||
Ok(())
|
||||
}
|
||||
None => {
|
||||
let mut main_file_path = path.clone();
|
||||
let mut main_file_path = path;
|
||||
main_file_path.push(SOURCE_DIRECTORY_NAME);
|
||||
main_file_path.push(MAIN_FILENAME);
|
||||
|
||||
|
@ -65,7 +65,7 @@ impl CLI for LintCommand {
|
||||
Ok(())
|
||||
}
|
||||
None => {
|
||||
let mut main_file_path = path.clone();
|
||||
let mut main_file_path = path;
|
||||
main_file_path.push(SOURCE_DIRECTORY_NAME);
|
||||
main_file_path.push(MAIN_FILENAME);
|
||||
|
||||
|
@ -146,7 +146,7 @@ impl CLI for SetupCommand {
|
||||
Ok((program, proving_key, prepared_verifying_key))
|
||||
}
|
||||
None => {
|
||||
let mut main_file_path = path.clone();
|
||||
let mut main_file_path = path;
|
||||
main_file_path.push(SOURCE_DIRECTORY_NAME);
|
||||
main_file_path.push(MAIN_FILENAME);
|
||||
|
||||
|
@ -60,7 +60,7 @@ impl CLI for TestCommand {
|
||||
let package_name = manifest.get_package_name();
|
||||
|
||||
// Sanitize the package path to the root directory
|
||||
let mut package_path = path.clone();
|
||||
let mut package_path = path;
|
||||
if package_path.is_file() {
|
||||
package_path.pop();
|
||||
}
|
||||
@ -93,8 +93,8 @@ impl CLI for TestCommand {
|
||||
|
||||
// Parse the current main program file
|
||||
let program = Compiler::<Fq, EdwardsGroupType>::parse_program_without_input(
|
||||
package_name.clone(),
|
||||
file_path.clone(),
|
||||
package_name,
|
||||
file_path,
|
||||
output_directory,
|
||||
)?;
|
||||
|
||||
@ -102,7 +102,7 @@ impl CLI for TestCommand {
|
||||
let pairs = InputPairs::try_from(&package_path)?;
|
||||
|
||||
// Run tests
|
||||
let temporary_program = program.clone();
|
||||
let temporary_program = program;
|
||||
let (passed, failed) = temporary_program.compile_test_constraints(pairs)?;
|
||||
|
||||
// Drop "Test" context for console logging
|
||||
|
@ -131,7 +131,7 @@ pub fn write_token(token: &str) -> Result<(), io::Error> {
|
||||
let config_dir = LEO_CONFIG_DIRECTORY.clone();
|
||||
|
||||
// Create Leo config directory if it not exists
|
||||
if !Path::new(&config_dir.to_path_buf()).exists() {
|
||||
if !Path::new(&config_dir).exists() {
|
||||
create_dir_all(&config_dir)?;
|
||||
}
|
||||
|
||||
|
@ -36,8 +36,8 @@ impl From<Index> for SerializedIndex {
|
||||
impl From<&SerializedIndex> for Index {
|
||||
fn from(serialized_index: &SerializedIndex) -> Self {
|
||||
match serialized_index {
|
||||
SerializedIndex::Input(idx) => Index::Input(idx.clone()),
|
||||
SerializedIndex::Aux(idx) => Index::Aux(idx.clone()),
|
||||
SerializedIndex::Input(idx) => Index::Input(*idx),
|
||||
SerializedIndex::Aux(idx) => Index::Aux(*idx),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user