diff --git a/asg/src/const_value.rs b/asg/src/const_value.rs index d430f0bbc4..cfe091f749 100644 --- a/asg/src/const_value.rs +++ b/asg/src/const_value.rs @@ -315,16 +315,16 @@ impl ConstInt { pub fn parse(int_type: &IntegerType, value: &str, span: &Span) -> Result { Ok(match int_type { - IntegerType::I8 => ConstInt::I8(value.parse().map_err(|_| AsgConvertError::invalid_int(&value, span))?), - IntegerType::I16 => ConstInt::I16(value.parse().map_err(|_| AsgConvertError::invalid_int(&value, span))?), - IntegerType::I32 => ConstInt::I32(value.parse().map_err(|_| AsgConvertError::invalid_int(&value, span))?), - IntegerType::I64 => ConstInt::I64(value.parse().map_err(|_| AsgConvertError::invalid_int(&value, span))?), - IntegerType::I128 => ConstInt::I128(value.parse().map_err(|_| AsgConvertError::invalid_int(&value, span))?), - IntegerType::U8 => ConstInt::U8(value.parse().map_err(|_| AsgConvertError::invalid_int(&value, span))?), - IntegerType::U16 => ConstInt::U16(value.parse().map_err(|_| AsgConvertError::invalid_int(&value, span))?), - IntegerType::U32 => ConstInt::U32(value.parse().map_err(|_| AsgConvertError::invalid_int(&value, span))?), - IntegerType::U64 => ConstInt::U64(value.parse().map_err(|_| AsgConvertError::invalid_int(&value, span))?), - IntegerType::U128 => ConstInt::U128(value.parse().map_err(|_| AsgConvertError::invalid_int(&value, span))?), + IntegerType::I8 => ConstInt::I8(value.parse().map_err(|_| AsgConvertError::invalid_int(value, span))?), + IntegerType::I16 => ConstInt::I16(value.parse().map_err(|_| AsgConvertError::invalid_int(value, span))?), + IntegerType::I32 => ConstInt::I32(value.parse().map_err(|_| AsgConvertError::invalid_int(value, span))?), + IntegerType::I64 => ConstInt::I64(value.parse().map_err(|_| AsgConvertError::invalid_int(value, span))?), + IntegerType::I128 => ConstInt::I128(value.parse().map_err(|_| AsgConvertError::invalid_int(value, span))?), + IntegerType::U8 => ConstInt::U8(value.parse().map_err(|_| AsgConvertError::invalid_int(value, span))?), + IntegerType::U16 => ConstInt::U16(value.parse().map_err(|_| AsgConvertError::invalid_int(value, span))?), + IntegerType::U32 => ConstInt::U32(value.parse().map_err(|_| AsgConvertError::invalid_int(value, span))?), + IntegerType::U64 => ConstInt::U64(value.parse().map_err(|_| AsgConvertError::invalid_int(value, span))?), + IntegerType::U128 => ConstInt::U128(value.parse().map_err(|_| AsgConvertError::invalid_int(value, span))?), }) } } diff --git a/asg/src/expression/constant.rs b/asg/src/expression/constant.rs index 8fb638974a..ae50b01071 100644 --- a/asg/src/expression/constant.rs +++ b/asg/src/expression/constant.rs @@ -115,7 +115,7 @@ impl<'a> FromAst<'a, leo_ast::ValueExpression> for Constant<'a> { value: ConstValue::Boolean( value .parse::() - .map_err(|_| AsgConvertError::invalid_boolean(&value, span))?, + .map_err(|_| AsgConvertError::invalid_boolean(value, span))?, ), } } @@ -151,7 +151,7 @@ impl<'a> FromAst<'a, leo_ast::ValueExpression> for Constant<'a> { Constant { parent: Cell::new(None), span: Some(span.clone()), - value: ConstValue::Field(value.parse().map_err(|_| AsgConvertError::invalid_int(&value, span))?), + value: ConstValue::Field(value.parse().map_err(|_| AsgConvertError::invalid_int(value, span))?), } } Group(value) => { @@ -188,7 +188,7 @@ impl<'a> FromAst<'a, leo_ast::ValueExpression> for Constant<'a> { Some(PartialType::Type(Type::Field)) => Constant { parent: Cell::new(None), span: Some(span.clone()), - value: ConstValue::Field(value.parse().map_err(|_| AsgConvertError::invalid_int(&value, span))?), + value: ConstValue::Field(value.parse().map_err(|_| AsgConvertError::invalid_int(value, span))?), }, Some(PartialType::Type(Type::Group)) => Constant { parent: Cell::new(None), diff --git a/asg/src/expression/mod.rs b/asg/src/expression/mod.rs index 4778e3b6a6..60c9d3f47c 100644 --- a/asg/src/expression/mod.rs +++ b/asg/src/expression/mod.rs @@ -341,7 +341,7 @@ impl<'a> FromAst<'a, leo_ast::Expression> for &'a Expression<'a> { .context .alloc_expression(CallExpression::from_ast(scope, call, expected_type).map(Expression::Call)?), }; - expression.enforce_parents(&expression); + expression.enforce_parents(expression); Ok(expression) } } diff --git a/asg/src/program/function.rs b/asg/src/program/function.rs index bf89b0020f..91b8a223f3 100644 --- a/asg/src/program/function.rs +++ b/asg/src/program/function.rs @@ -101,7 +101,7 @@ impl<'a> Function<'a> { let variable = scope.context.alloc_variable(RefCell::new(crate::InnerVariable { id: scope.context.get_id(), name: identifier.clone(), - type_: scope.resolve_ast_type(&type_)?, + type_: scope.resolve_ast_type(type_)?, mutable: *mutable, const_: *const_, declaration: crate::VariableDeclaration::Parameter, diff --git a/asg/src/program/mod.rs b/asg/src/program/mod.rs index d6c00ef7e3..998f5928c5 100644 --- a/asg/src/program/mod.rs +++ b/asg/src/program/mod.rs @@ -127,7 +127,7 @@ fn resolve_import_package_access( PackageAccess::Multiple(packages) => { package_segments.push(packages.name.name.to_string()); for subaccess in packages.accesses.iter() { - resolve_import_package_access(output, package_segments.clone(), &subaccess); + resolve_import_package_access(output, package_segments.clone(), subaccess); } } } diff --git a/asg/src/reducer/monoidal_director.rs b/asg/src/reducer/monoidal_director.rs index 161183a19b..858a1bb256 100644 --- a/asg/src/reducer/monoidal_director.rs +++ b/asg/src/reducer/monoidal_director.rs @@ -308,6 +308,6 @@ impl<'a, T: Monoid, R: MonoidalReducerProgram<'a, T>> MonoidalDirector<'a, T, R> let circuits = input.circuits.iter().map(|(_, c)| self.reduce_circuit(c)).collect(); self.reducer - .reduce_program(&input, imported_modules, functions, circuits) + .reduce_program(input, imported_modules, functions, circuits) } } diff --git a/asg/src/statement/assign.rs b/asg/src/statement/assign.rs index e1f44b8210..1f3357d884 100644 --- a/asg/src/statement/assign.rs +++ b/asg/src/statement/assign.rs @@ -79,12 +79,12 @@ impl<'a> FromAst<'a, leo_ast::AssignStatement> for &'a Statement<'a> { } } else { scope - .resolve_variable(&name) - .ok_or_else(|| AsgConvertError::unresolved_reference(name, &span))? + .resolve_variable(name) + .ok_or_else(|| AsgConvertError::unresolved_reference(name, span))? }; if !variable.borrow().mutable { - return Err(AsgConvertError::immutable_assignment(&name, &statement.span)); + return Err(AsgConvertError::immutable_assignment(name, &statement.span)); } let mut target_type: Option = Some(variable.borrow().type_.clone().into()); @@ -123,13 +123,13 @@ impl<'a> FromAst<'a, leo_ast::AssignStatement> for &'a Statement<'a> { ) { let left = match left { ConstValue::Int(x) => x.to_usize().ok_or_else(|| { - AsgConvertError::invalid_assign_index(&name, &x.to_string(), &statement.span) + AsgConvertError::invalid_assign_index(name, &x.to_string(), &statement.span) })?, _ => unimplemented!(), }; let right = match right { ConstValue::Int(x) => x.to_usize().ok_or_else(|| { - AsgConvertError::invalid_assign_index(&name, &x.to_string(), &statement.span) + AsgConvertError::invalid_assign_index(name, &x.to_string(), &statement.span) })?, _ => unimplemented!(), }; @@ -137,7 +137,7 @@ impl<'a> FromAst<'a, leo_ast::AssignStatement> for &'a Statement<'a> { target_type = Some(PartialType::Array(item.clone(), Some((right - left) as usize))) } else { return Err(AsgConvertError::invalid_backwards_assignment( - &name, + name, left, right, &statement.span, @@ -145,7 +145,7 @@ impl<'a> FromAst<'a, leo_ast::AssignStatement> for &'a Statement<'a> { } } } - _ => return Err(AsgConvertError::index_into_non_array(&name, &statement.span)), + _ => return Err(AsgConvertError::index_into_non_array(name, &statement.span)), } AssignAccess::ArrayRange(Cell::new(left), Cell::new(right)) @@ -153,7 +153,7 @@ impl<'a> FromAst<'a, leo_ast::AssignStatement> for &'a Statement<'a> { AstAssigneeAccess::ArrayIndex(index) => { target_type = match target_type.clone() { Some(PartialType::Array(item, _)) => item.map(|x| *x), - _ => return Err(AsgConvertError::index_into_non_array(&name, &statement.span)), + _ => return Err(AsgConvertError::index_into_non_array(name, &statement.span)), }; AssignAccess::ArrayIndex(Cell::new(<&Expression<'a>>::from_ast( scope, @@ -171,7 +171,7 @@ impl<'a> FromAst<'a, leo_ast::AssignStatement> for &'a Statement<'a> { .get(index) .cloned() .ok_or_else(|| AsgConvertError::tuple_index_out_of_bounds(index, &statement.span))?, - _ => return Err(AsgConvertError::index_into_non_tuple(&name, &statement.span)), + _ => return Err(AsgConvertError::index_into_non_tuple(name, &statement.span)), }; AssignAccess::Tuple(index) } diff --git a/asg/src/statement/block.rs b/asg/src/statement/block.rs index 9a64fcdfb9..2b50d0c3df 100644 --- a/asg/src/statement/block.rs +++ b/asg/src/statement/block.rs @@ -42,7 +42,7 @@ impl<'a> FromAst<'a, leo_ast::Block> for BlockStatement<'a> { let mut output = vec![]; for item in statement.statements.iter() { - output.push(Cell::new(<&'a Statement<'a>>::from_ast(&new_scope, item, None)?)); + output.push(Cell::new(<&'a Statement<'a>>::from_ast(new_scope, item, None)?)); } Ok(BlockStatement { parent: Cell::new(None), diff --git a/asg/src/statement/definition.rs b/asg/src/statement/definition.rs index f340052409..54bdf50b4f 100644 --- a/asg/src/statement/definition.rs +++ b/asg/src/statement/definition.rs @@ -70,7 +70,7 @@ impl<'a> FromAst<'a, leo_ast::DefinitionStatement> for &'a Statement<'a> { let type_ = statement .type_ .as_ref() - .map(|x| scope.resolve_ast_type(&x)) + .map(|x| scope.resolve_ast_type(x)) .transpose()?; let value = <&Expression<'a>>::from_ast(scope, &statement.value, type_.clone().map(Into::into))?; diff --git a/compiler/src/compiler.rs b/compiler/src/compiler.rs index 34e55b7a7f..5efb919e2a 100644 --- a/compiler/src/compiler.rs +++ b/compiler/src/compiler.rs @@ -181,7 +181,7 @@ impl<'a, F: PrimeField, G: GroupType> Compiler<'a, F, G> { state_string: &str, state_path: &Path, ) -> Result<(), CompilerError> { - let input_syntax_tree = LeoInputParser::parse_file(&input_string).map_err(|mut e| { + let input_syntax_tree = LeoInputParser::parse_file(input_string).map_err(|mut e| { e.set_path( input_path.to_str().unwrap_or_default(), &input_string.lines().map(|x| x.to_string()).collect::>()[..], @@ -189,7 +189,7 @@ impl<'a, F: PrimeField, G: GroupType> Compiler<'a, F, G> { e })?; - let state_syntax_tree = LeoInputParser::parse_file(&state_string).map_err(|mut e| { + let state_syntax_tree = LeoInputParser::parse_file(state_string).map_err(|mut e| { e.set_path( state_path.to_str().unwrap_or_default(), &state_string.lines().map(|x| x.to_string()).collect::>()[..], @@ -308,14 +308,14 @@ impl<'a, F: PrimeField, G: GroupType> Compiler<'a, F, G> { /// Synthesizes the circuit with program input to verify correctness. /// pub fn compile_constraints>(&self, cs: &mut CS) -> Result { - generate_constraints::(cs, &self.asg.as_ref().unwrap(), &self.program_input) + generate_constraints::(cs, self.asg.as_ref().unwrap(), &self.program_input) } /// /// Synthesizes the circuit for test functions with program input. /// pub fn compile_test_constraints(self, input_pairs: InputPairs) -> Result<(u32, u32), CompilerError> { - generate_test_constraints::(&self.asg.as_ref().unwrap(), input_pairs, &self.output_directory) + generate_test_constraints::(self.asg.as_ref().unwrap(), input_pairs, &self.output_directory) } /// diff --git a/compiler/src/constraints/constraints.rs b/compiler/src/constraints/constraints.rs index 6d256dea96..4e34b4c096 100644 --- a/compiler/src/constraints/constraints.rs +++ b/compiler/src/constraints/constraints.rs @@ -44,7 +44,7 @@ pub fn generate_constraints<'a, F: PrimeField, G: GroupType, CS: ConstraintSy match main { Some(function) => { - let result = resolved_program.enforce_main_function(cs, &function, input)?; + let result = resolved_program.enforce_main_function(cs, function, input)?; Ok(result) } _ => Err(CompilerError::NoMainFunction), diff --git a/compiler/src/expression/array/access.rs b/compiler/src/expression/array/access.rs index 11009dbd64..0fd6e7f5fb 100644 --- a/compiler/src/expression/array/access.rs +++ b/compiler/src/expression/array/access.rs @@ -94,7 +94,7 @@ impl<'a, F: PrimeField, G: GroupType> ConstrainedProgram<'a, F, G> { .len() .try_into() .map_err(|_| ExpressionError::array_length_out_of_bounds(span))?; - self.array_bounds_check(cs, &&index_resolved, array_len, span)?; + self.array_bounds_check(cs, &index_resolved, array_len, span)?; } let mut current_value = array.pop().unwrap(); diff --git a/compiler/src/expression/function/function.rs b/compiler/src/expression/function/function.rs index e67700d7a8..58f2f0b3d4 100644 --- a/compiler/src/expression/function/function.rs +++ b/compiler/src/expression/function/function.rs @@ -44,7 +44,7 @@ impl<'a, F: PrimeField, G: GroupType> ConstrainedProgram<'a, F, G> { }; let return_value = self - .enforce_function(&mut cs.ns(name_unique), &function, target, arguments) + .enforce_function(&mut cs.ns(name_unique), function, target, arguments) .map_err(|error| ExpressionError::from(Box::new(error)))?; Ok(return_value) diff --git a/compiler/src/function/input/main_function_input.rs b/compiler/src/function/input/main_function_input.rs index 75379676fe..ec55db0a92 100644 --- a/compiler/src/function/input/main_function_input.rs +++ b/compiler/src/function/input/main_function_input.rs @@ -62,7 +62,7 @@ impl<'a, F: PrimeField, G: GroupType> ConstrainedProgram<'a, F, G> { span, )?)), Type::Array(type_, len) => self.allocate_array(cs, name, &*type_, *len, input_option, span), - Type::Tuple(types) => self.allocate_tuple(cs, &name, types, input_option, span), + Type::Tuple(types) => self.allocate_tuple(cs, name, types, input_option, span), _ => unimplemented!("main function input not implemented for type {}", type_), // Should not happen. } } diff --git a/compiler/src/function/main_function.rs b/compiler/src/function/main_function.rs index 8fe7e3a635..2e615924dc 100644 --- a/compiler/src/function/main_function.rs +++ b/compiler/src/function/main_function.rs @@ -39,7 +39,7 @@ impl<'a, F: PrimeField, G: GroupType> ConstrainedProgram<'a, F, G> { if let Some(asg_input) = asg_input { let value = - self.allocate_input_keyword(cs, &function.name.borrow().span, &asg_input.container_circuit, input)?; + self.allocate_input_keyword(cs, &function.name.borrow().span, asg_input.container_circuit, input)?; self.store(asg_input.container.borrow().id, value); } diff --git a/compiler/src/function/result/result.rs b/compiler/src/function/result/result.rs index a0f71b896c..395cf39adb 100644 --- a/compiler/src/function/result/result.rs +++ b/compiler/src/function/result/result.rs @@ -82,7 +82,7 @@ impl<'a, F: PrimeField, G: GroupType> ConstrainedProgram<'a, F, G> { cs.ns(|| format!("select result {} {}:{}", i, span.line_start, span.col_start)), &indicator, &result, - &value, + value, ) .map_err(|_| StatementError::select_fail(result.to_string(), value.to_string(), span))?, ); @@ -94,7 +94,7 @@ impl<'a, F: PrimeField, G: GroupType> ConstrainedProgram<'a, F, G> { if expected_return.is_unit() { Ok(ConstrainedValue::Tuple(vec![])) } else { - return_value.ok_or_else(|| StatementError::no_returns(&expected_return, span)) + return_value.ok_or_else(|| StatementError::no_returns(expected_return, span)) } } } diff --git a/compiler/src/phases/reducing_director.rs b/compiler/src/phases/reducing_director.rs index 2a934909a8..6cec43764d 100644 --- a/compiler/src/phases/reducing_director.rs +++ b/compiler/src/phases/reducing_director.rs @@ -155,49 +155,49 @@ impl CombineAstAsgDirector { asg: &AsgExpression, ) -> Result { let new = match (ast, asg) { - (AstExpression::Value(value), AsgExpression::Constant(const_)) => self.reduce_value(&value, &const_)?, + (AstExpression::Value(value), AsgExpression::Constant(const_)) => self.reduce_value(value, const_)?, (AstExpression::Binary(ast), AsgExpression::Binary(asg)) => { - AstExpression::Binary(self.reduce_binary(&ast, &asg)?) + AstExpression::Binary(self.reduce_binary(ast, asg)?) } (AstExpression::Unary(ast), AsgExpression::Unary(asg)) => { - AstExpression::Unary(self.reduce_unary(&ast, &asg)?) + AstExpression::Unary(self.reduce_unary(ast, asg)?) } (AstExpression::Ternary(ast), AsgExpression::Ternary(asg)) => { - AstExpression::Ternary(self.reduce_ternary(&ast, &asg)?) + AstExpression::Ternary(self.reduce_ternary(ast, asg)?) } - (AstExpression::Cast(ast), AsgExpression::Cast(asg)) => AstExpression::Cast(self.reduce_cast(&ast, &asg)?), + (AstExpression::Cast(ast), AsgExpression::Cast(asg)) => AstExpression::Cast(self.reduce_cast(ast, asg)?), (AstExpression::ArrayInline(ast), AsgExpression::ArrayInline(asg)) => { - AstExpression::ArrayInline(self.reduce_array_inline(&ast, &asg)?) + AstExpression::ArrayInline(self.reduce_array_inline(ast, asg)?) } (AstExpression::ArrayInit(ast), AsgExpression::ArrayInit(asg)) => { - AstExpression::ArrayInit(self.reduce_array_init(&ast, &asg)?) + AstExpression::ArrayInit(self.reduce_array_init(ast, asg)?) } (AstExpression::ArrayAccess(ast), AsgExpression::ArrayAccess(asg)) => { - AstExpression::ArrayAccess(self.reduce_array_access(&ast, &asg)?) + AstExpression::ArrayAccess(self.reduce_array_access(ast, asg)?) } (AstExpression::ArrayRangeAccess(ast), AsgExpression::ArrayRangeAccess(asg)) => { - AstExpression::ArrayRangeAccess(self.reduce_array_range_access(&ast, &asg)?) + AstExpression::ArrayRangeAccess(self.reduce_array_range_access(ast, asg)?) } (AstExpression::TupleInit(ast), AsgExpression::TupleInit(asg)) => { - AstExpression::TupleInit(self.reduce_tuple_init(&ast, &asg)?) + AstExpression::TupleInit(self.reduce_tuple_init(ast, asg)?) } (AstExpression::TupleAccess(ast), AsgExpression::TupleAccess(asg)) => { - AstExpression::TupleAccess(self.reduce_tuple_access(&ast, &asg)?) + AstExpression::TupleAccess(self.reduce_tuple_access(ast, asg)?) } (AstExpression::CircuitInit(ast), AsgExpression::CircuitInit(asg)) => { - AstExpression::CircuitInit(self.reduce_circuit_init(&ast, &asg)?) + AstExpression::CircuitInit(self.reduce_circuit_init(ast, asg)?) } (AstExpression::CircuitMemberAccess(ast), AsgExpression::CircuitAccess(asg)) => { - AstExpression::CircuitMemberAccess(self.reduce_circuit_member_access(&ast, &asg)?) + AstExpression::CircuitMemberAccess(self.reduce_circuit_member_access(ast, asg)?) } (AstExpression::CircuitStaticFunctionAccess(ast), AsgExpression::CircuitAccess(asg)) => { - AstExpression::CircuitStaticFunctionAccess(self.reduce_circuit_static_fn_access(&ast, &asg)?) + AstExpression::CircuitStaticFunctionAccess(self.reduce_circuit_static_fn_access(ast, asg)?) } - (AstExpression::Call(ast), AsgExpression::Call(asg)) => AstExpression::Call(self.reduce_call(&ast, &asg)?), + (AstExpression::Call(ast), AsgExpression::Call(asg)) => AstExpression::Call(self.reduce_call(ast, asg)?), _ => ast.clone(), }; @@ -299,7 +299,7 @@ impl CombineAstAsgDirector { ast: &AstCastExpression, asg: &AsgCastExpression, ) -> Result { - let inner = self.reduce_expression(&ast.inner, &asg.inner.get())?; + let inner = self.reduce_expression(&ast.inner, asg.inner.get())?; let target_type = self.reduce_type(&ast.target_type, &asg.target_type, &ast.span)?; self.ast_reducer.reduce_cast(ast, inner, target_type) @@ -524,7 +524,7 @@ impl CombineAstAsgDirector { AstAssignAccess::ArrayRange(left, right) } (AstAssignAccess::ArrayIndex(ast_index), AsgAssignAccess::ArrayIndex(asg_index)) => { - let index = self.reduce_expression(&ast_index, asg_index.get())?; + let index = self.reduce_expression(ast_index, asg_index.get())?; AstAssignAccess::ArrayIndex(index) } _ => ast.clone(), @@ -577,7 +577,7 @@ impl CombineAstAsgDirector { block = self.reduce_block(&ast.block, asg_block)?; } else { return Err(ReducerError::from(CombinerError::asg_statement_not_block( - &asg.span.as_ref().unwrap(), + asg.span.as_ref().unwrap(), ))); } let next = match (ast.next.as_ref(), asg.next.get()) { @@ -595,7 +595,7 @@ impl CombineAstAsgDirector { ) -> Result { let function = match (&ast.function, &asg.function) { (AstConsoleFunction::Assert(ast_expression), AsgConsoleFunction::Assert(asg_expression)) => { - AstConsoleFunction::Assert(self.reduce_expression(&ast_expression, asg_expression.get())?) + AstConsoleFunction::Assert(self.reduce_expression(ast_expression, asg_expression.get())?) } (AstConsoleFunction::Error(ast_console_args), AsgConsoleFunction::Error(asg_format)) | (AstConsoleFunction::Log(ast_console_args), AsgConsoleFunction::Log(asg_format)) => { @@ -603,7 +603,7 @@ impl CombineAstAsgDirector { for (ast_parameter, asg_parameter) in ast_console_args.parameters.iter().zip(asg_format.parameters.iter()) { - parameters.push(self.reduce_expression(&ast_parameter, asg_parameter.get())?); + parameters.push(self.reduce_expression(ast_parameter, asg_parameter.get())?); } let args = AstConsoleArgs { @@ -640,14 +640,14 @@ impl CombineAstAsgDirector { let asg_type = AsgType::Tuple(types); type_ = match &ast.type_ { - Some(ast_type) => Some(self.reduce_type(&ast_type, &asg_type, &ast.span)?), + Some(ast_type) => Some(self.reduce_type(ast_type, &asg_type, &ast.span)?), None if self.options.type_inference_enabled() => Some((&asg_type).into()), _ => None, }; } else { type_ = match &ast.type_ { Some(ast_type) => { - Some(self.reduce_type(&ast_type, &asg.variables.first().unwrap().borrow().type_, &ast.span)?) + Some(self.reduce_type(ast_type, &asg.variables.first().unwrap().borrow().type_, &ast.span)?) } None if self.options.type_inference_enabled() => { Some((&asg.variables.first().unwrap().borrow().type_).into()) @@ -683,7 +683,7 @@ impl CombineAstAsgDirector { block = self.reduce_block(&ast.block, asg_block)?; } else { return Err(ReducerError::from(CombinerError::asg_statement_not_block( - &asg.span.as_ref().unwrap(), + asg.span.as_ref().unwrap(), ))); } diff --git a/compiler/src/statement/assign/assignee/array_index.rs b/compiler/src/statement/assign/assignee/array_index.rs index 4b7fc6f3b0..4a463fe3cf 100644 --- a/compiler/src/statement/assign/assignee/array_index.rs +++ b/compiler/src/statement/assign/assignee/array_index.rs @@ -69,7 +69,7 @@ impl<'a, F: PrimeField, G: GroupType> ConstrainedProgram<'a, F, G> { .len() .try_into() .map_err(|_| ExpressionError::array_length_out_of_bounds(&span))?; - self.array_bounds_check(cs, &&index_resolved, array_len, &span)?; + self.array_bounds_check(cs, &index_resolved, array_len, &span)?; } for (i, item) in input.iter_mut().enumerate() { @@ -116,7 +116,7 @@ impl<'a, F: PrimeField, G: GroupType> ConstrainedProgram<'a, F, G> { unique_namespace, &index_comparison, &temp_item, - &item, + item, ) .map_err(|e| ExpressionError::cannot_enforce("conditional select".to_string(), e, &span))?; *item = value; @@ -153,7 +153,7 @@ impl<'a, F: PrimeField, G: GroupType> ConstrainedProgram<'a, F, G> { .len() .try_into() .map_err(|_| ExpressionError::array_length_out_of_bounds(&span))?; - self.array_bounds_check(cs, &&index_resolved, array_len, &span)?; + self.array_bounds_check(cs, &index_resolved, array_len, &span)?; } for (i, item) in context.input.iter_mut().enumerate() { @@ -197,7 +197,7 @@ impl<'a, F: PrimeField, G: GroupType> ConstrainedProgram<'a, F, G> { item }; let value = - ConstrainedValue::conditionally_select(unique_namespace, &index_comparison, &temp_item, &item) + ConstrainedValue::conditionally_select(unique_namespace, &index_comparison, &temp_item, item) .map_err(|e| ExpressionError::cannot_enforce("conditional select".to_string(), e, &span))?; **item = value; } diff --git a/compiler/src/statement/conditional/conditional.rs b/compiler/src/statement/conditional/conditional.rs index 3fe7469209..79b032c0e5 100644 --- a/compiler/src/statement/conditional/conditional.rs +++ b/compiler/src/statement/conditional/conditional.rs @@ -91,7 +91,7 @@ impl<'a, F: PrimeField, G: GroupType> ConstrainedProgram<'a, F, G> { ); let branch_2_indicator = Boolean::and( &mut cs.ns(|| format!("branch 2 {}:{}", &span.line_start, &span.col_start)), - &outer_indicator, + outer_indicator, &inner_indicator, ) .map_err(|_| StatementError::indicator_calculation(branch_2_name, &span))?; diff --git a/compiler/src/value/value.rs b/compiler/src/value/value.rs index eb23ec9843..158879d57a 100644 --- a/compiler/src/value/value.rs +++ b/compiler/src/value/value.rs @@ -124,7 +124,7 @@ impl<'a, F: PrimeField, G: GroupType> fmt::Display for ConstrainedValue<'a, F write!(f, "({})", values) } - ConstrainedValue::CircuitExpression(ref circuit, ref members) => { + ConstrainedValue::CircuitExpression(circuit, ref members) => { write!(f, "{} {{", circuit.name.borrow())?; for (i, member) in members.iter().enumerate() { write!(f, "{}: {}", member.0, member.1)?; diff --git a/imports/src/parser/parse_symbol.rs b/imports/src/parser/parse_symbol.rs index ce1f391f60..1b8183f7b0 100644 --- a/imports/src/parser/parse_symbol.rs +++ b/imports/src/parser/parse_symbol.rs @@ -54,7 +54,7 @@ impl<'a> ImportParser<'a> { // Build the package abstract syntax tree. let program_string = &std::fs::read_to_string(&file_path).map_err(|x| ImportParserError::io_error(span, file_path_str, x))?; - let mut program = leo_parser::parse(&file_path_str, &program_string)?; + let mut program = leo_parser::parse(file_path_str, program_string)?; program.name = file_name; let mut ast = leo_ast::Ast::new(program); ast.canonicalize()?; diff --git a/leo/config.rs b/leo/config.rs index ae85bc3d2c..ccba67ef0b 100644 --- a/leo/config.rs +++ b/leo/config.rs @@ -144,10 +144,10 @@ pub fn write_token_and_username(token: &str, username: &str) -> Result<(), io::E } let mut credentials = File::create(&LEO_CREDENTIALS_PATH.to_path_buf())?; - credentials.write_all(&token.as_bytes())?; + credentials.write_all(token.as_bytes())?; let mut username_file = File::create(&LEO_USERNAME_PATH.to_path_buf())?; - username_file.write_all(&username.as_bytes())?; + username_file.write_all(username.as_bytes())?; Ok(()) } diff --git a/leo/updater.rs b/leo/updater.rs index cc5c8972da..a5e5b7668a 100644 --- a/leo/updater.rs +++ b/leo/updater.rs @@ -53,7 +53,7 @@ impl Updater { .repo_owner(Self::LEO_REPO_OWNER) .repo_name(Self::LEO_REPO_NAME) .bin_name(Self::LEO_BIN_NAME) - .current_version(&env!("CARGO_PKG_VERSION")) + .current_version(env!("CARGO_PKG_VERSION")) .show_download_progress(show_output) .no_confirm(true) .show_output(show_output) @@ -69,7 +69,7 @@ impl Updater { .repo_owner(Self::LEO_REPO_OWNER) .repo_name(Self::LEO_REPO_NAME) .bin_name(Self::LEO_BIN_NAME) - .current_version(&env!("CARGO_PKG_VERSION")) + .current_version(env!("CARGO_PKG_VERSION")) .build()?; let current_version = updater.current_version(); diff --git a/package/src/package.rs b/package/src/package.rs index 8a7fb861e7..1a6b8273de 100644 --- a/package/src/package.rs +++ b/package/src/package.rs @@ -123,14 +123,14 @@ impl Package { } // Check if the input file already exists. - let input_file = InputFile::new(&package_name); + let input_file = InputFile::new(package_name); if input_file.exists_at(path) { existing_files.push(input_file.filename()); result = false; } // Check if the state file already exists. - let state_file = StateFile::new(&package_name); + let state_file = StateFile::new(package_name); if state_file.exists_at(path) { existing_files.push(state_file.filename()); result = false; @@ -157,24 +157,24 @@ impl Package { } // Check if the manifest file exists. - if !Manifest::exists_at(&path) { + if !Manifest::exists_at(path) { return false; } // Check if the input file exists. - let input_file = InputFile::new(&package_name); - if !input_file.exists_at(&path) { + let input_file = InputFile::new(package_name); + if !input_file.exists_at(path) { return false; } // Check if the state file exists. - let state_file = StateFile::new(&package_name); - if !state_file.exists_at(&path) { + let state_file = StateFile::new(package_name); + if !state_file.exists_at(path) { return false; } // Check if the main file exists. - if !MainFile::exists_at(&path) { + if !MainFile::exists_at(path) { return false; } @@ -195,34 +195,34 @@ impl Package { // Next, initialize this directory as a Leo package. { // Create the manifest file. - Manifest::new(&package_name, author)?.write_to(&path)?; + Manifest::new(package_name, author)?.write_to(path)?; // Verify that the .gitignore file does not exist. - if !Gitignore::exists_at(&path) { + if !Gitignore::exists_at(path) { // Create the .gitignore file. - Gitignore::new().write_to(&path)?; + Gitignore::new().write_to(path)?; } // Verify that the README.md file does not exist. - if !README::exists_at(&path) { + if !README::exists_at(path) { // Create the README.md file. - README::new(package_name).write_to(&path)?; + README::new(package_name).write_to(path)?; } // Create the source directory. - SourceDirectory::create(&path)?; + SourceDirectory::create(path)?; // Create the input directory. - InputsDirectory::create(&path)?; + InputsDirectory::create(path)?; // Create the input file in the inputs directory. - InputFile::new(&package_name).write_to(&path)?; + InputFile::new(package_name).write_to(path)?; // Create the state file in the inputs directory. - StateFile::new(&package_name).write_to(&path)?; + StateFile::new(package_name).write_to(path)?; // Create the main file in the source directory. - MainFile::new(&package_name).write_to(&path)?; + MainFile::new(package_name).write_to(path)?; } // Next, verify that a valid Leo package has been initialized in this directory {