Add clippy (#191)

* Organize imports

Use rustfmt to organize imports.  Resolve #162

* remove unused imports

* Fix clippy complaints

* add clippy github action

* remove comment for @arnaucube
This commit is contained in:
Eduard S. 2025-04-08 11:52:02 -07:00 committed by GitHub
parent 24ff82dd3d
commit 0759d6e165
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
27 changed files with 217 additions and 339 deletions

View file

@ -201,10 +201,9 @@ impl ToFields for StatementTmpl {
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
/// NOTE: fields are not public (outside of crate) to enforce the struct instantiation through
/// the `::and/or` methods, which performs checks on the values.
pub struct CustomPredicate {
/// NOTE: fields are not public (outside of crate) to enforce the struct instantiation through
/// the `::and/or` methods, which performs checks on the values.
/// true for "and", false for "or"
pub(crate) conjunction: bool,
pub(crate) statements: Vec<StatementTmpl>,

View file

@ -197,6 +197,7 @@ pub trait Pod: fmt::Debug + DynClone {
}
// Used for downcasting
fn into_any(self: Box<Self>) -> Box<dyn Any>;
fn as_any(&self) -> &dyn Any;
// Front-end Pods keep references to middleware Pods. Most of the
// middleware data can be derived directly from front-end data, but the
// "proof" data is only created at the point of proving/signing, and
@ -233,6 +234,9 @@ impl Pod for NonePod {
fn into_any(self: Box<Self>) -> Box<dyn Any> {
self
}
fn as_any(&self) -> &dyn Any {
self
}
fn serialized_proof(&self) -> String {
"".to_string()
}
@ -240,8 +244,8 @@ impl Pod for NonePod {
#[derive(Debug)]
pub struct MainPodInputs<'a> {
pub signed_pods: &'a [&'a Box<dyn Pod>],
pub main_pods: &'a [&'a Box<dyn Pod>],
pub signed_pods: &'a [&'a dyn Pod],
pub main_pods: &'a [&'a dyn Pod],
pub statements: &'a [Statement],
pub operations: &'a [Operation],
/// Statements that need to be made public (they can come from input pods or input

View file

@ -180,8 +180,8 @@ impl Operation {
Self::TransitiveEqualFromStatements(s1, s2) => vec![s1, s2],
Self::GtToNotEqual(s) => vec![s],
Self::LtToNotEqual(s) => vec![s],
Self::ContainsFromEntries(s1, s2, s3, pf) => vec![s1, s2, s3],
Self::NotContainsFromEntries(s1, s2, pf) => vec![s1, s2],
Self::ContainsFromEntries(s1, s2, s3, _pf) => vec![s1, s2, s3],
Self::NotContainsFromEntries(s1, s2, _pf) => vec![s1, s2],
Self::SumOf(s1, s2, s3) => vec![s1, s2, s3],
Self::ProductOf(s1, s2, s3) => vec![s1, s2, s3],
Self::MaxOf(s1, s2, s3) => vec![s1, s2, s3],
@ -303,7 +303,7 @@ impl Operation {
}
Self::TransitiveEqualFromStatements(Equal(ak1, ak2), Equal(ak3, ak4)) => {
if ak2 == ak3 {
Some(vec![StatementArg::Key(*ak1), StatementArg::Key(*ak3)])
Some(vec![StatementArg::Key(*ak1), StatementArg::Key(*ak4)])
} else {
return Err(anyhow!("Invalid operation"));
}
@ -324,7 +324,7 @@ impl Operation {
return Err(anyhow!("Invalid operation"));
}
Self::ContainsFromEntries(ValueOf(ak1, v1), ValueOf(ak2, v2), ValueOf(ak3, v3), pf)
if MerkleTree::verify(pf.siblings.len(), (*v1).into(), &pf, v2, v3)? == () =>
if MerkleTree::verify(pf.siblings.len(), (*v1).into(), pf, v2, v3).is_ok() =>
{
Some(vec![
StatementArg::Key(*ak1),
@ -336,8 +336,8 @@ impl Operation {
return Err(anyhow!("Invalid operation"));
}
Self::NotContainsFromEntries(ValueOf(ak1, v1), ValueOf(ak2, v2), pf)
if MerkleTree::verify_nonexistence(pf.siblings.len(), (*v1).into(), &pf, v2)?
== () =>
if MerkleTree::verify_nonexistence(pf.siblings.len(), (*v1).into(), pf, v2)
.is_ok() =>
{
Some(vec![StatementArg::Key(*ak1), StatementArg::Key(*ak2)])
}
@ -349,7 +349,11 @@ impl Operation {
let v2: i64 = (*v2).try_into()?;
let v3: i64 = (*v3).try_into()?;
if v1 == v2 + v3 {
Some(vec![StatementArg::Key(*ak1), StatementArg::Key(*ak2)])
Some(vec![
StatementArg::Key(*ak1),
StatementArg::Key(*ak2),
StatementArg::Key(*ak3),
])
} else {
return Err(anyhow!("Invalid operation"));
}
@ -362,7 +366,11 @@ impl Operation {
let v2: i64 = (*v2).try_into()?;
let v3: i64 = (*v3).try_into()?;
if v1 == v2 * v3 {
Some(vec![StatementArg::Key(*ak1), StatementArg::Key(*ak2)])
Some(vec![
StatementArg::Key(*ak1),
StatementArg::Key(*ak2),
StatementArg::Key(*ak3),
])
} else {
return Err(anyhow!("Invalid operation"));
}
@ -375,7 +383,11 @@ impl Operation {
let v2: i64 = (*v2).try_into()?;
let v3: i64 = (*v3).try_into()?;
if v1 == std::cmp::max(v2, v3) {
Some(vec![StatementArg::Key(*ak1), StatementArg::Key(*ak2)])
Some(vec![
StatementArg::Key(*ak1),
StatementArg::Key(*ak2),
StatementArg::Key(*ak3),
])
} else {
return Err(anyhow!("Invalid operation"));
}
@ -484,7 +496,7 @@ impl Operation {
}
impl ToFields for Operation {
fn to_fields(&self, params: &Params) -> Vec<F> {
fn to_fields(&self, _params: &Params) -> Vec<F> {
todo!()
}
}

View file

@ -29,11 +29,11 @@ where
}
let mut v = [F::ZERO; N];
for i in 0..N {
for (i, v_i) in v.iter_mut().enumerate() {
let start = i * 16;
let end = start + 16;
let hex_part = &hex_str[start..end];
v[i] = F::from_canonical_u64(
*v_i = F::from_canonical_u64(
u64::from_str_radix(hex_part, 16).map_err(serde::de::Error::custom)?,
);
}