clippy: fix large_enum_variant

Signed-off-by: ljedrz <ljedrz@gmail.com>
This commit is contained in:
ljedrz 2020-10-06 09:51:54 +02:00
parent c4cdaed923
commit ba9fc92229
5 changed files with 33 additions and 33 deletions

View File

@ -77,7 +77,7 @@ impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
function_scope, function_scope,
indicator, indicator,
variable_name, variable_name,
range_or_expression, *range_or_expression,
new_value, new_value,
span, span,
), ),

View File

@ -71,7 +71,7 @@ impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
declared_circuit_reference, declared_circuit_reference,
indicator, indicator,
variable, variable,
expression, *expression,
span, span,
)?; )?;
} }
@ -95,8 +95,8 @@ impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
function_scope, function_scope,
indicator, indicator,
index, index,
start, *start,
stop, *stop,
statements, statements,
return_type, return_type,
span, span,

View File

@ -48,7 +48,7 @@ use std::{
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub enum EdwardsGroupType { pub enum EdwardsGroupType {
Constant(EdwardsAffine), Constant(EdwardsAffine),
Allocated(EdwardsBlsGadget), Allocated(Box<EdwardsBlsGadget>),
} }
impl GroupType<Fq> for EdwardsGroupType { impl GroupType<Fq> for EdwardsGroupType {
@ -60,7 +60,7 @@ impl GroupType<Fq> for EdwardsGroupType {
fn to_allocated<CS: ConstraintSystem<Fq>>(&self, mut cs: CS, span: Span) -> Result<Self, GroupError> { fn to_allocated<CS: ConstraintSystem<Fq>>(&self, mut cs: CS, span: Span) -> Result<Self, GroupError> {
self.allocated(cs.ns(|| format!("allocate affine point {}:{}", span.line, span.start))) self.allocated(cs.ns(|| format!("allocate affine point {}:{}", span.line, span.start)))
.map(|result| EdwardsGroupType::Allocated(result)) .map(|ebg| EdwardsGroupType::Allocated(Box::new(ebg)))
.map_err(|error| GroupError::synthesis_error(error, span)) .map_err(|error| GroupError::synthesis_error(error, span))
} }
@ -71,7 +71,7 @@ impl GroupType<Fq> for EdwardsGroupType {
let result = <EdwardsBlsGadget as GroupGadget<GroupAffine<EdwardsParameters>, Fq>>::negate(group, cs) let result = <EdwardsBlsGadget as GroupGadget<GroupAffine<EdwardsParameters>, Fq>>::negate(group, cs)
.map_err(|e| GroupError::negate_operation(e, span))?; .map_err(|e| GroupError::negate_operation(e, span))?;
Ok(EdwardsGroupType::Allocated(result)) Ok(EdwardsGroupType::Allocated(Box::new(result)))
} }
} }
} }
@ -90,16 +90,16 @@ impl GroupType<Fq> for EdwardsGroupType {
) )
.map_err(|e| GroupError::binary_operation("+".to_string(), e, span))?; .map_err(|e| GroupError::binary_operation("+".to_string(), e, span))?;
Ok(EdwardsGroupType::Allocated(result)) Ok(EdwardsGroupType::Allocated(Box::new(result)))
} }
(EdwardsGroupType::Constant(constant_value), EdwardsGroupType::Allocated(allocated_value)) (EdwardsGroupType::Constant(constant_value), EdwardsGroupType::Allocated(allocated_value))
| (EdwardsGroupType::Allocated(allocated_value), EdwardsGroupType::Constant(constant_value)) => { | (EdwardsGroupType::Allocated(allocated_value), EdwardsGroupType::Constant(constant_value)) => {
Ok(EdwardsGroupType::Allocated( Ok(EdwardsGroupType::Allocated(Box::new(
allocated_value allocated_value
.add_constant(cs, constant_value) .add_constant(cs, constant_value)
.map_err(|e| GroupError::binary_operation("+".to_string(), e, span))?, .map_err(|e| GroupError::binary_operation("+".to_string(), e, span))?,
)) )))
} }
} }
} }
@ -118,16 +118,16 @@ impl GroupType<Fq> for EdwardsGroupType {
) )
.map_err(|e| GroupError::binary_operation("-".to_string(), e, span))?; .map_err(|e| GroupError::binary_operation("-".to_string(), e, span))?;
Ok(EdwardsGroupType::Allocated(result)) Ok(EdwardsGroupType::Allocated(Box::new(result)))
} }
(EdwardsGroupType::Constant(constant_value), EdwardsGroupType::Allocated(allocated_value)) (EdwardsGroupType::Constant(constant_value), EdwardsGroupType::Allocated(allocated_value))
| (EdwardsGroupType::Allocated(allocated_value), EdwardsGroupType::Constant(constant_value)) => { | (EdwardsGroupType::Allocated(allocated_value), EdwardsGroupType::Constant(constant_value)) => {
Ok(EdwardsGroupType::Allocated( Ok(EdwardsGroupType::Allocated(Box::new(
allocated_value allocated_value
.sub_constant(cs, constant_value) .sub_constant(cs, constant_value)
.map_err(|e| GroupError::binary_operation("-".to_string(), e, span))?, .map_err(|e| GroupError::binary_operation("-".to_string(), e, span))?,
)) )))
} }
} }
} }
@ -316,7 +316,7 @@ impl AllocGadget<GroupValue, Fq> for EdwardsGroupType {
Self::alloc_helper(value_gen) Self::alloc_helper(value_gen)
})?; })?;
Ok(EdwardsGroupType::Allocated(value)) Ok(EdwardsGroupType::Allocated(Box::new(value)))
} }
fn alloc_input<Fn: FnOnce() -> Result<T, SynthesisError>, T: Borrow<GroupValue>, CS: ConstraintSystem<Fq>>( fn alloc_input<Fn: FnOnce() -> Result<T, SynthesisError>, T: Borrow<GroupValue>, CS: ConstraintSystem<Fq>>(
@ -327,7 +327,7 @@ impl AllocGadget<GroupValue, Fq> for EdwardsGroupType {
Self::alloc_helper(value_gen) Self::alloc_helper(value_gen)
})?; })?;
Ok(EdwardsGroupType::Allocated(value)) Ok(EdwardsGroupType::Allocated(Box::new(value)))
} }
} }
@ -454,7 +454,7 @@ impl CondSelectGadget<Fq> for EdwardsGroupType {
let second_gadget = second.allocated(cs.ns(|| "second"))?; let second_gadget = second.allocated(cs.ns(|| "second"))?;
let result = EdwardsBlsGadget::conditionally_select(cs, cond, &first_gadget, &second_gadget)?; let result = EdwardsBlsGadget::conditionally_select(cs, cond, &first_gadget, &second_gadget)?;
Ok(EdwardsGroupType::Allocated(result)) Ok(EdwardsGroupType::Allocated(Box::new(result)))
} }
} }

View File

@ -27,7 +27,7 @@ use std::fmt;
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub enum Assignee { pub enum Assignee {
Identifier(Identifier), Identifier(Identifier),
Array(Box<Assignee>, RangeOrExpression), Array(Box<Assignee>, Box<RangeOrExpression>),
Tuple(Box<Assignee>, usize), Tuple(Box<Assignee>, usize),
CircuitField(Box<Assignee>, Identifier), // (circuit name, circuit field name) CircuitField(Box<Assignee>, Identifier), // (circuit name, circuit field name)
} }
@ -54,7 +54,7 @@ impl<'ast> From<AstAssignee<'ast>> for Assignee {
.into_iter() .into_iter()
.fold(variable, |acc, access| match access { .fold(variable, |acc, access| match access {
AstAssigneeAccess::Array(array) => { AstAssigneeAccess::Array(array) => {
Assignee::Array(Box::new(acc), RangeOrExpression::from(array.expression)) Assignee::Array(Box::new(acc), Box::new(RangeOrExpression::from(array.expression)))
} }
AstAssigneeAccess::Tuple(tuple) => { AstAssigneeAccess::Tuple(tuple) => {
Assignee::Tuple(Box::new(acc), Expression::get_count_from_ast(tuple.number)) Assignee::Tuple(Box::new(acc), Expression::get_count_from_ast(tuple.number))

View File

@ -36,9 +36,9 @@ use std::fmt;
pub enum Statement { pub enum Statement {
Return(Expression, Span), Return(Expression, Span),
Definition(Declare, Variables, Vec<Expression>, Span), Definition(Declare, Variables, Vec<Expression>, Span),
Assign(Assignee, Expression, Span), Assign(Assignee, Box<Expression>, Span),
Conditional(ConditionalStatement, Span), Conditional(ConditionalStatement, Span),
Iteration(Identifier, Expression, Expression, Vec<Statement>, Span), Iteration(Identifier, Box<Expression>, Box<Expression>, Vec<Statement>, Span),
Console(ConsoleFunctionCall), Console(ConsoleFunctionCall),
Expression(Expression, Span), Expression(Expression, Span),
} }
@ -78,7 +78,7 @@ impl<'ast> From<AssignStatement<'ast>> for Statement {
match statement.assign { match statement.assign {
AssignOperation::Assign(ref _assign) => Statement::Assign( AssignOperation::Assign(ref _assign) => Statement::Assign(
Assignee::from(statement.assignee), Assignee::from(statement.assignee),
Expression::from(statement.expression), Box::new(Expression::from(statement.expression)),
Span::from(statement.span), Span::from(statement.span),
), ),
operation_assign => { operation_assign => {
@ -88,47 +88,47 @@ impl<'ast> From<AssignStatement<'ast>> for Statement {
match operation_assign { match operation_assign {
AssignOperation::AddAssign(ref _assign) => Statement::Assign( AssignOperation::AddAssign(ref _assign) => Statement::Assign(
Assignee::from(statement.assignee), Assignee::from(statement.assignee),
Expression::Add( Box::new(Expression::Add(
Box::new(converted), Box::new(converted),
Box::new(Expression::from(statement.expression)), Box::new(Expression::from(statement.expression)),
Span::from(statement.span.clone()), Span::from(statement.span.clone()),
), )),
Span::from(statement.span), Span::from(statement.span),
), ),
AssignOperation::SubAssign(ref _assign) => Statement::Assign( AssignOperation::SubAssign(ref _assign) => Statement::Assign(
Assignee::from(statement.assignee), Assignee::from(statement.assignee),
Expression::Sub( Box::new(Expression::Sub(
Box::new(converted), Box::new(converted),
Box::new(Expression::from(statement.expression)), Box::new(Expression::from(statement.expression)),
Span::from(statement.span.clone()), Span::from(statement.span.clone()),
), )),
Span::from(statement.span), Span::from(statement.span),
), ),
AssignOperation::MulAssign(ref _assign) => Statement::Assign( AssignOperation::MulAssign(ref _assign) => Statement::Assign(
Assignee::from(statement.assignee), Assignee::from(statement.assignee),
Expression::Mul( Box::new(Expression::Mul(
Box::new(converted), Box::new(converted),
Box::new(Expression::from(statement.expression)), Box::new(Expression::from(statement.expression)),
Span::from(statement.span.clone()), Span::from(statement.span.clone()),
), )),
Span::from(statement.span), Span::from(statement.span),
), ),
AssignOperation::DivAssign(ref _assign) => Statement::Assign( AssignOperation::DivAssign(ref _assign) => Statement::Assign(
Assignee::from(statement.assignee), Assignee::from(statement.assignee),
Expression::Div( Box::new(Expression::Div(
Box::new(converted), Box::new(converted),
Box::new(Expression::from(statement.expression)), Box::new(Expression::from(statement.expression)),
Span::from(statement.span.clone()), Span::from(statement.span.clone()),
), )),
Span::from(statement.span), Span::from(statement.span),
), ),
AssignOperation::PowAssign(ref _assign) => Statement::Assign( AssignOperation::PowAssign(ref _assign) => Statement::Assign(
Assignee::from(statement.assignee), Assignee::from(statement.assignee),
Expression::Pow( Box::new(Expression::Pow(
Box::new(converted), Box::new(converted),
Box::new(Expression::from(statement.expression)), Box::new(Expression::from(statement.expression)),
Span::from(statement.span.clone()), Span::from(statement.span.clone()),
), )),
Span::from(statement.span), Span::from(statement.span),
), ),
AssignOperation::Assign(ref _assign) => unimplemented!("cannot assign twice to assign statement"), AssignOperation::Assign(ref _assign) => unimplemented!("cannot assign twice to assign statement"),
@ -142,8 +142,8 @@ impl<'ast> From<ForStatement<'ast>> for Statement {
fn from(statement: ForStatement<'ast>) -> Self { fn from(statement: ForStatement<'ast>) -> Self {
Statement::Iteration( Statement::Iteration(
Identifier::from(statement.index), Identifier::from(statement.index),
Expression::from(statement.start), Box::new(Expression::from(statement.start)),
Expression::from(statement.stop), Box::new(Expression::from(statement.stop)),
statement statement
.statements .statements
.into_iter() .into_iter()