Add strict clippy lints to 7 crates and fix all warnings#3480
Add strict clippy lints to 7 crates and fix all warnings#3480dannywillems merged 12 commits intomasterfrom
Conversation
aa3695d to
ecb2ba8
Compare
richardpringle
left a comment
There was a problem hiding this comment.
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() | ||
| } | ||
| } |
There was a problem hiding this comment.
🤔 where did this come from
| let basis_refs: Vec<_> = basis.iter().collect(); | ||
| PolyComm::<G>::multi_scalar_mul(&basis_refs, evals) |
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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()) |
There was a problem hiding this comment.
This is a behaviour change
| panic!( | ||
| "Error encoding lagrange basis to file {}", | ||
| cache_key.display() | ||
| ) |
| 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())); |
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
2343dae to
7cccd82
Compare
Summary
#![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-commitmentonce_cell::sync::Lazywithstd::sync::LazyLockin poly-commitment (removesonce_celldependency)Key changes per crate:
#[must_use], idiomatic patternsconst fn, idiomatic patterns#[must_use],# Errors/# PanicssectionsSelfusage,const fn#[must_use]#[must_use],from_biguintnow takes&BigUint, removed needless collectsLazyLockmigration,#[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 warningspasses cleancargo test -p o1-utils --release(23 tests pass)cargo test -p poly-commitment --release(15 tests pass)