clippy fixes

This commit is contained in:
damirka 2021-08-03 01:46:18 +03:00
parent 34f1c00da2
commit 82f8e8a5ca
24 changed files with 91 additions and 91 deletions

View File

@ -315,16 +315,16 @@ impl ConstInt {
pub fn parse(int_type: &IntegerType, value: &str, span: &Span) -> Result<ConstInt, AsgConvertError> {
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))?),
})
}
}

View File

@ -115,7 +115,7 @@ impl<'a> FromAst<'a, leo_ast::ValueExpression> for Constant<'a> {
value: ConstValue::Boolean(
value
.parse::<bool>()
.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),

View File

@ -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)
}
}

View File

@ -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,

View File

@ -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);
}
}
}

View File

@ -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)
}
}

View File

@ -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<PartialType> = 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)
}

View File

@ -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),

View File

@ -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))?;

View File

@ -181,7 +181,7 @@ impl<'a, F: PrimeField, G: GroupType<F>> 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::<Vec<String>>()[..],
@ -189,7 +189,7 @@ impl<'a, F: PrimeField, G: GroupType<F>> 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::<Vec<String>>()[..],
@ -308,14 +308,14 @@ impl<'a, F: PrimeField, G: GroupType<F>> Compiler<'a, F, G> {
/// Synthesizes the circuit with program input to verify correctness.
///
pub fn compile_constraints<CS: ConstraintSystem<F>>(&self, cs: &mut CS) -> Result<Output, CompilerError> {
generate_constraints::<F, G, CS>(cs, &self.asg.as_ref().unwrap(), &self.program_input)
generate_constraints::<F, G, CS>(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::<F, G>(&self.asg.as_ref().unwrap(), input_pairs, &self.output_directory)
generate_test_constraints::<F, G>(self.asg.as_ref().unwrap(), input_pairs, &self.output_directory)
}
///

View File

@ -44,7 +44,7 @@ pub fn generate_constraints<'a, F: PrimeField, G: GroupType<F>, 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),

View File

@ -94,7 +94,7 @@ impl<'a, F: PrimeField, G: GroupType<F>> 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();

View File

@ -44,7 +44,7 @@ impl<'a, F: PrimeField, G: GroupType<F>> 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)

View File

@ -62,7 +62,7 @@ impl<'a, F: PrimeField, G: GroupType<F>> 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.
}
}

View File

@ -39,7 +39,7 @@ impl<'a, F: PrimeField, G: GroupType<F>> 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);
}

View File

@ -82,7 +82,7 @@ impl<'a, F: PrimeField, G: GroupType<F>> 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<F>> 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))
}
}
}

View File

@ -155,49 +155,49 @@ impl<R: ReconstructingReducer, O: CombinerOptions> CombineAstAsgDirector<R, O> {
asg: &AsgExpression,
) -> Result<AstExpression, ReducerError> {
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<R: ReconstructingReducer, O: CombinerOptions> CombineAstAsgDirector<R, O> {
ast: &AstCastExpression,
asg: &AsgCastExpression,
) -> Result<AstCastExpression, ReducerError> {
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<R: ReconstructingReducer, O: CombinerOptions> CombineAstAsgDirector<R, O> {
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<R: ReconstructingReducer, O: CombinerOptions> CombineAstAsgDirector<R, O> {
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<R: ReconstructingReducer, O: CombinerOptions> CombineAstAsgDirector<R, O> {
) -> Result<AstConsoleStatement, ReducerError> {
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<R: ReconstructingReducer, O: CombinerOptions> CombineAstAsgDirector<R, O> {
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<R: ReconstructingReducer, O: CombinerOptions> CombineAstAsgDirector<R, O> {
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<R: ReconstructingReducer, O: CombinerOptions> CombineAstAsgDirector<R, O> {
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(),
)));
}

View File

@ -69,7 +69,7 @@ impl<'a, F: PrimeField, G: GroupType<F>> 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<F>> 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<F>> 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<F>> 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;
}

View File

@ -91,7 +91,7 @@ impl<'a, F: PrimeField, G: GroupType<F>> 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))?;

View File

@ -124,7 +124,7 @@ impl<'a, F: PrimeField, G: GroupType<F>> 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)?;

View File

@ -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()?;

View File

@ -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(())
}

View File

@ -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();

View File

@ -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
{