1
0
Fork 0
mirror of synced 2025-09-23 04:08:33 +00:00
This commit is contained in:
dark64 2021-12-10 15:08:15 +01:00
parent 71c74e5962
commit 95a931c579
10 changed files with 29 additions and 38 deletions

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -344,17 +344,14 @@ 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 {
BooleanExpression::And(box left, box right) => {
self.current.push(left);
self.current.push(right);
self.next()
}
n => Some(n),
})
.flatten()
self.current.pop().and_then(|n| match n {
BooleanExpression::And(box left, box right) => {
self.current.push(left);
self.current.push(right);
self.next()
}
n => Some(n),
})
}
}

View file

@ -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| {
vec![
var_to_index(&q.x, num_instance_variables),
var_to_index(&q.y, num_instance_variables),
]
})
.flatten(),
);
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),
]
}));
let out_index = match &res {
Boolean::Is(x) => x

View file

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

View file

@ -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!(