Skip to content

Add strict clippy lints to 7 crates and fix all warnings#3480

Merged
dannywillems merged 12 commits intomasterfrom
dw/mina-hasher-hardening
Feb 7, 2026
Merged

Add strict clippy lints to 7 crates and fix all warnings#3480
dannywillems merged 12 commits intomasterfrom
dw/mina-hasher-hardening

Conversation

@dannywillems
Copy link
Member

Summary

  • Add #![deny(clippy::all, clippy::pedantic, clippy::nursery, unsafe_code)] to 7 crates: mina-hasher, mina-poseidon, mina-signer, mina-curves, groupmap, o1-utils, and poly-commitment
  • Fix all resulting clippy warnings across 52 files (~770 insertions, ~400 deletions)
  • Replace once_cell::sync::Lazy with std::sync::LazyLock in poly-commitment (removes once_cell dependency)

Key changes per crate:

  • mina-hasher: doc improvements, #[must_use], idiomatic patterns
  • mina-poseidon: doc improvements, const fn, idiomatic patterns
  • mina-signer: doc improvements, #[must_use], # Errors/# Panics sections
  • mina-curves: doc improvements, Self usage, const fn
  • groupmap: doc improvements, #[must_use]
  • o1-utils: doc improvements, #[must_use], from_biguint now takes &BigUint, removed needless collects
  • poly-commitment: doc improvements with rustdoc links, LazyLock migration, #[must_use]/const fn, div_ceil, &[T] instead of &Vec<T>

Test plan

  • cargo clippy -p mina-hasher -p mina-poseidon -p mina-signer -p mina-curves -p groupmap -p o1-utils -p poly-commitment -- -D warnings passes clean
  • cargo test -p o1-utils --release (23 tests pass)
  • cargo test -p poly-commitment --release (15 tests pass)
  • CI passes for all affected crates

@dannywillems dannywillems self-assigned this Feb 6, 2026
@dannywillems dannywillems moved this to In Review in Rust node Feb 6, 2026
@dannywillems dannywillems force-pushed the dw/mina-hasher-hardening branch from aa3695d to ecb2ba8 Compare February 6, 2026 20:34
Copy link
Contributor

@richardpringle richardpringle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving, but there were a bunch of panic messages that have actually changed here. I'm not sure if that matters

pub fn iter(&self) -> std::slice::Iter<'_, G> {
self.chunks.iter()
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔 where did this come from

Comment on lines +585 to +586
let basis_refs: Vec<_> = basis.iter().collect();
PolyComm::<G>::multi_scalar_mul(&basis_refs, evals)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But whyyyyy. I really hope the compiler does a good job optimizing the completely redundant allocation away.

I don't know what the multi_scalar_mul signature looks like, but I'm surprised clippy isn't complaining about &Vec. We allocate a vector just to get access to borrowed values instead of owned ones. There so much wrong with this. Usually clippy::pedantic will tell you that &Vec and &String are always a mistake (Unless you need to know the capacity for some strange reason, you should be using &[T] and &str).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is probably super inefficient by the way... there's a lot of indirection iterating over all the pointers to the values instead of just using a slice.

let basis: Vec<PolyComm<G>> =
rmp_serde::decode::from_read(f).unwrap_or_else(|_| {
panic!("Error decoding lagrange cache file {:?}", cache_key)
panic!("Error decoding lagrange cache file {}", cache_key.display())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a behaviour change

panic!(
"Error encoding lagrange basis to file {}",
cache_key.display()
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same with these

let file =
File::open(srs_path.clone()).unwrap_or_else(|_| panic!("missing SRS file: {srs_path:?}"));
let file = File::open(srs_path.clone())
.unwrap_or_else(|_| panic!("missing SRS file: {}", srs_path.display()));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another change

Add #![deny(clippy::all, clippy::pedantic, clippy::nursery, unsafe_code)]
to mina-hasher crate and fix all resulting lint errors including doc
improvements, #[must_use] annotations, and idiomatic Rust patterns.
Add #![deny(clippy::all, clippy::pedantic, clippy::nursery, unsafe_code)]
to mina-poseidon crate and fix all resulting lint errors including doc
improvements, const fn annotations, and idiomatic Rust patterns.
Add #![deny(clippy::all, clippy::pedantic, clippy::nursery, unsafe_code)]
to mina-signer crate and fix all resulting lint errors including doc
improvements, #[must_use] annotations, and # Errors/# Panics sections.
Add #![deny(clippy::all, clippy::pedantic, clippy::nursery, unsafe_code)]
to mina-curves crate and fix all resulting lint errors including doc
improvements, Self usage, and const fn annotations.
Add #![deny(clippy::all, clippy::pedantic, clippy::nursery, unsafe_code)]
to groupmap crate and fix all resulting lint errors including doc
improvements and #[must_use] annotations.
Add #![deny(clippy::all, clippy::pedantic, clippy::nursery, unsafe_code)]
to o1-utils crate and fix all resulting lint errors including doc
improvements, #[must_use] annotations, needless_pass_by_value fixes
(from_biguint now takes &BigUint), and idiomatic Rust patterns.
Add #![deny(clippy::all, clippy::pedantic, clippy::nursery, unsafe_code)]
to poly-commitment crate and fix all 154 resulting lint errors. Key
changes include doc improvements with rustdoc links, #[must_use] and
const fn annotations, replacing once_cell with std::sync::LazyLock,
removing needless collects, and using idiomatic Rust patterns throughout.
Fix clippy errors that only appear with --all-features --all-targets:
- Update all ForeignElement::from_biguint callers in kimchi to pass
  &BigUint after the API change
- Fix plonk-wasm batch_dlog_accumulator_generate caller for &[T] param
- Fix wildcard import in poseidon caml module (needed by ocaml_gen macro)
- Fix long literals, missing semicolons, uninlined format args, similar
  variable names, and other pedantic lints in test code
- Format CHANGELOG.md with prettier
@dannywillems dannywillems force-pushed the dw/mina-hasher-hardening branch from 2343dae to 7cccd82 Compare February 7, 2026 13:41
@dannywillems dannywillems merged commit dcba897 into master Feb 7, 2026
31 checks passed
@dannywillems dannywillems deleted the dw/mina-hasher-hardening branch February 7, 2026 13:58
@yamimaio yamimaio moved this from In Review to Done in Rust node Feb 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants