clippy
This commit is contained in:
parent
71c74e5962
commit
95a931c579
10 changed files with 29 additions and 38 deletions
|
@ -74,7 +74,7 @@ fn cli_check<T: Field>(sub_matches: &ArgMatches) -> Result<(), String> {
|
|||
format!(
|
||||
"{}:{}",
|
||||
file.strip_prefix(std::env::current_dir().unwrap())
|
||||
.unwrap_or_else(|_| file.as_path())
|
||||
.unwrap_or(file.as_path())
|
||||
.display(),
|
||||
e.value()
|
||||
)
|
||||
|
|
|
@ -90,7 +90,7 @@ fn cli_compile<T: Field>(sub_matches: &ArgMatches) -> Result<(), String> {
|
|||
format!(
|
||||
"{}:{}",
|
||||
file.strip_prefix(std::env::current_dir().unwrap())
|
||||
.unwrap_or_else(|_| file.as_path())
|
||||
.unwrap_or(file.as_path())
|
||||
.display(),
|
||||
e.value()
|
||||
)
|
||||
|
|
|
@ -137,6 +137,7 @@ pub enum SymbolDefinition<'ast> {
|
|||
Function(FunctionNode<'ast>),
|
||||
}
|
||||
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
#[derive(Debug, PartialEq, Clone)]
|
||||
pub enum Symbol<'ast> {
|
||||
Here(SymbolDefinition<'ast>),
|
||||
|
|
|
@ -257,8 +257,7 @@ impl<'ast, 'a, T: Field> ResultFolder<'ast, T> for Reducer<'ast, 'a, T> {
|
|||
}
|
||||
Err(InlineError::Generic(decl, conc)) => Err(Error::Incompatible(format!(
|
||||
"Call site `{}` incompatible with declaration `{}`",
|
||||
conc.to_string(),
|
||||
decl.to_string()
|
||||
conc, decl
|
||||
))),
|
||||
Err(InlineError::NonConstant(key, generics, arguments, _)) => {
|
||||
self.complete = false;
|
||||
|
@ -388,8 +387,7 @@ impl<'ast, 'a, T: Field> ResultFolder<'ast, T> for Reducer<'ast, 'a, T> {
|
|||
}
|
||||
Err(InlineError::Generic(decl, conc)) => Err(Error::Incompatible(format!(
|
||||
"Call site `{}` incompatible with declaration `{}`",
|
||||
conc.to_string(),
|
||||
decl.to_string()
|
||||
conc, decl
|
||||
))),
|
||||
Err(InlineError::NonConstant(key, generics, arguments, output_types)) => {
|
||||
self.complete = false;
|
||||
|
@ -442,8 +440,7 @@ impl<'ast, 'a, T: Field> ResultFolder<'ast, T> for Reducer<'ast, 'a, T> {
|
|||
UExpression::from(index as u32).into(),
|
||||
))
|
||||
.chain(statements.clone().into_iter())
|
||||
.map(|s| transformer.fold_statement(s))
|
||||
.flatten()
|
||||
.flat_map(|s| transformer.fold_statement(s))
|
||||
.collect();
|
||||
|
||||
out_statements.extend(statements);
|
||||
|
|
|
@ -147,7 +147,7 @@ impl<'ast, T: Field> ResultFolder<'ast, T> for ZirPropagator<'ast, T> {
|
|||
UExpressionInner::Value(v) => e
|
||||
.get(v as usize)
|
||||
.cloned()
|
||||
.ok_or_else(|| Error::OutOfBounds(v, e.len() as u128)),
|
||||
.ok_or(Error::OutOfBounds(v, e.len() as u128)),
|
||||
i => Ok(FieldElementExpression::Select(
|
||||
e,
|
||||
box i.annotate(UBitwidth::B32),
|
||||
|
@ -279,7 +279,7 @@ impl<'ast, T: Field> ResultFolder<'ast, T> for ZirPropagator<'ast, T> {
|
|||
UExpressionInner::Value(v) => e
|
||||
.get(*v as usize)
|
||||
.cloned()
|
||||
.ok_or_else(|| Error::OutOfBounds(*v, e.len() as u128)),
|
||||
.ok_or(Error::OutOfBounds(*v, e.len() as u128)),
|
||||
_ => Ok(BooleanExpression::Select(e, box index)),
|
||||
}
|
||||
}
|
||||
|
@ -498,7 +498,7 @@ impl<'ast, T: Field> ResultFolder<'ast, T> for ZirPropagator<'ast, T> {
|
|||
UExpressionInner::Value(v) => e
|
||||
.get(v as usize)
|
||||
.cloned()
|
||||
.ok_or_else(|| Error::OutOfBounds(v, e.len() as u128))
|
||||
.ok_or(Error::OutOfBounds(v, e.len() as u128))
|
||||
.map(|e| e.into_inner()),
|
||||
i => Ok(UExpressionInner::Select(e, box i.annotate(UBitwidth::B32))),
|
||||
}
|
||||
|
|
|
@ -190,6 +190,7 @@ impl<'ast, T> TypedConstantSymbolDeclaration<'ast, T> {
|
|||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
#[derive(PartialEq, Debug, Clone)]
|
||||
pub enum TypedSymbolDeclaration<'ast, T> {
|
||||
Function(TypedFunctionSymbolDeclaration<'ast, T>),
|
||||
|
@ -424,6 +425,7 @@ impl<'ast, T: Field> Typed<'ast, T> for TypedConstant<'ast, T> {
|
|||
}
|
||||
|
||||
/// Something we can assign to.
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
#[derive(Clone, PartialEq, Debug, Hash, Eq, PartialOrd, Ord)]
|
||||
pub enum TypedAssignee<'ast, T> {
|
||||
Identifier(Variable<'ast, T>),
|
||||
|
@ -1243,8 +1245,7 @@ impl<'ast, T: Clone> ArrayValue<'ast, T> {
|
|||
) -> Option<U> {
|
||||
self.0
|
||||
.iter()
|
||||
.map(|v| Self::expression_at_aux(v.clone()))
|
||||
.flatten()
|
||||
.flat_map(|v| Self::expression_at_aux(v.clone()))
|
||||
.take_while(|e| e.is_some())
|
||||
.map(|e| e.unwrap())
|
||||
.nth(index)
|
||||
|
|
|
@ -344,9 +344,7 @@ impl<'ast, T> Iterator for ConjunctionIterator<BooleanExpression<'ast, T>> {
|
|||
type Item = BooleanExpression<'ast, T>;
|
||||
|
||||
fn next(&mut self) -> Option<Self::Item> {
|
||||
self.current
|
||||
.pop()
|
||||
.map(|n| match n {
|
||||
self.current.pop().and_then(|n| match n {
|
||||
BooleanExpression::And(box left, box right) => {
|
||||
self.current.push(left);
|
||||
self.current.push(right);
|
||||
|
@ -354,7 +352,6 @@ impl<'ast, T> Iterator for ConjunctionIterator<BooleanExpression<'ast, T>> {
|
|||
}
|
||||
n => Some(n),
|
||||
})
|
||||
.flatten()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -144,17 +144,12 @@ pub fn generate_verify_constraints(
|
|||
var_to_index(&vk.h_gamma_g2.y.c1, num_instance_variables),
|
||||
];
|
||||
|
||||
vk_indices.extend(
|
||||
vk.query
|
||||
.iter()
|
||||
.map(|q| {
|
||||
vk_indices.extend(vk.query.iter().flat_map(|q| {
|
||||
vec![
|
||||
var_to_index(&q.x, num_instance_variables),
|
||||
var_to_index(&q.y, num_instance_variables),
|
||||
]
|
||||
})
|
||||
.flatten(),
|
||||
);
|
||||
}));
|
||||
|
||||
let out_index = match &res {
|
||||
Boolean::Is(x) => x
|
||||
|
|
|
@ -705,7 +705,7 @@ mod ast {
|
|||
#[derive(Debug, FromPest, PartialEq, Clone)]
|
||||
#[pest_ast(rule(Rule::assignee_access))]
|
||||
pub enum AssigneeAccess<'ast> {
|
||||
Select(ArrayAccess<'ast>),
|
||||
Select(Box<ArrayAccess<'ast>>),
|
||||
Member(MemberAccess<'ast>),
|
||||
}
|
||||
|
||||
|
|
|
@ -28,9 +28,9 @@ fn write_test<W: Write>(test_file: &mut W, test_path: &Path, base_path: &Path) {
|
|||
.unwrap()
|
||||
.display()
|
||||
.to_string()
|
||||
.replace("/", "_")
|
||||
.replace('/', "_")
|
||||
.replace(".json", "")
|
||||
.replace(".", "")
|
||||
.replace('.', "")
|
||||
);
|
||||
|
||||
write!(
|
||||
|
|
Loading…
Reference in a new issue