Commit 966cb0d
authored
Resolve Clippy findings (#45)
* Applied the Clippy-suggested idioms across the utils crate so the reported lints now build cleanly.
- `crates/utils/src/misc.rs:33` switched the even-length assertions in the left/right slice helpers to `.is_multiple_of(2)` so Clippy stops flagging the manual modulus checks.
- `crates/utils/src/univariate.rs:9` introduced `CacheValue`/`SelectorsCache` type aliases and reused them in the `SELECTORS_CACHE` static to tame the complex type signature.
- `crates/utils/src/multilinear.rs:24` replaced the raw `transmute` with a typed pointer cast, and in `:186` rewrote the recursion branch to drop needless returns while using `point.is_empty()`. Tests at `:280` and `:298` now iterate directly over mutable coefficients, removing the range-index loops.
- `crates/utils/src/display.rs:8` now relies on `.is_multiple_of(3)` for clarity in the thousands separator logic.
Checks: `cargo fmt`
`cargo clippy --workspace --all-targets -- -Dwarnings` now continues past `crates/utils`, but fails later with pre-existing lints in `crates/packed_pcs` and `crates/sumcheck` (multiple bound locations, unused type parameter, `map`+`flatten`, needless borrows, function argument count). Those remain to be addressed separately.
Next steps:
1. Tackle the newly surfaced Clippy findings in `crates/packed_pcs` and `crates/sumcheck`, or relax the lint levels for those items if appropriate.
* - Updated `compute_chunks` and `num_packed_vars_for_dims` to drop the redundant `EF` parameter and return constraints, and reworked `packed_pcs_commit`’s generics so all trait bounds live in the `where` clause (`crates/packed_pcs/src/lib.rs:149`, `:181`, `:196`).
- Replaced the `map(...).flatten()` pattern with `flat_map`, avoided needless reborrows when looking up chunks, and compared boolean prefixes directly rather than taking extra references (`crates/packed_pcs/src/lib.rs:299`, `:310`, `:352`, `:500`).
- Adjusted verifier-side lookups to use the new chunk access pattern and the simplified comparisons (`crates/packed_pcs/src/lib.rs:465`, `:487`, `:500`).
- Updated the two call sites that still referenced the old `num_packed_vars_for_dims::<EF, EF>` signature (`crates/lean_prover/src/prove_execution.rs:992`, `crates/lean_prover/src/verify_execution.rs:548`).
Checks: `cargo fmt`. `cargo clippy --workspace --all-targets -- -Dwarnings` still stops at the existing `sumcheck` lints (too many arguments); no new warnings from `packed_pcs`.
Next steps:
1. Resolve the `clippy::too_many_arguments` reports in `crates/sumcheck/src/mle.rs` or suppress them if that’s intentional.
* - Introduced the `Poseidon2Config` workflow and split the prover/verifier logic into reusable helpers, which shrank the main entry point and dropped the lossless cast in `src/examples/prove_poseidon2.rs:18-275`; updated the CLI entrypoint to build that config once and pass it by reference (`src/main.rs:5-19`).
- Cleaned up the PCS stack: `compute_chunks`/`num_packed_vars_for_dims` now avoid redundant generics, the commit/global-statement helpers use iterators instead of `map(...).flatten()`, and dictionary lookups no longer take needless borrows (`crates/packed_pcs/src/lib.rs:149-332`).
- Refactored sumcheck execution to accept parameter structs instead of long argument lists and reused those structs for both packed and unpacked flows (`crates/sumcheck/src/mle.rs:309-517`, `crates/sumcheck/src/prove.rs:149-186`).
- Converted numerous range-index loops to iterator-based updates (e.g. `crates/lean_vm/src/memory.rs:32-38`, `crates/lean_prover/witness_generation/src/execution_trace.rs:270-276`, `crates/lean_prover/src/prove_execution.rs:802-824`, `crates/lean_prover/src/verify_execution.rs:862-872`) and collapsed deep `if let` chains in the AIR/Lean compiler stack (`crates/air/src/prove.rs:118-182`, `crates/air/src/verify.rs:187-281`, `crates/lean_compiler/src/a_simplify_lang.rs:681-707`, `crates/lean_compiler/src/b_compile_intermediate.rs:50-79`, `crates/lean_compiler/src/c_compile_final.rs:152-175`).
- Simplified and renamed helpers across the Lean prover pipeline: `get_base_dims` now groups its inputs into tuples (`crates/lean_prover/src/common.rs:16-39`); the runner uses a params struct instead of nine loose arguments and avoids redundant pointer casts (`crates/lean_vm/src/runner.rs:149-285`); bitfield generation no longer performs a modulo-by-one (`crates/rec_aggregation/src/xmss_aggregate.rs:215-231`); miscellaneous utilities use the standard `.is_multiple_of()` idiom (`crates/utils/src/misc.rs:32-53`, `crates/utils/src/display.rs:7-11`) and clarified cache aliases in `crates/utils/src/univariate.rs:9-13`.
Clippy: `cargo clippy --workspace --all-targets -- -Dwarnings`
* - Reworked the row-filling loops in `crates/air/src/test.rs:101-152` to eliminate range indexing: both structured and unstructured trace generators now walk column iterators row-by-row, keeping per-column state where needed and breaking cleanly when the iterators exhaust. This removes the needless index loop flagged by Clippy.
Tests: `cargo clippy -p air --tests -- -Dwarnings`1 parent 6144927 commit 966cb0d
File tree
24 files changed
+589
-362
lines changed- crates
- air/src
- lean_compiler/src
- lean_prover
- src
- witness_generation/src
- lean_vm/src
- lookup/src
- packed_pcs/src
- rec_aggregation/src
- sumcheck/src
- utils/src
- src
- examples
24 files changed
+589
-362
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
122 | 122 | | |
123 | 123 | | |
124 | 124 | | |
125 | | - | |
| 125 | + | |
126 | 126 | | |
127 | 127 | | |
128 | 128 | | |
| |||
132 | 132 | | |
133 | 133 | | |
134 | 134 | | |
135 | | - | |
| 135 | + | |
136 | 136 | | |
137 | 137 | | |
138 | 138 | | |
| |||
224 | 224 | | |
225 | 225 | | |
226 | 226 | | |
227 | | - | |
228 | | - | |
229 | | - | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
230 | 234 | | |
231 | 235 | | |
232 | 236 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
88 | 88 | | |
89 | 89 | | |
90 | 90 | | |
91 | 91 | | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
96 | 96 | | |
97 | 97 | | |
98 | 98 | | |
| |||
110 | 110 | | |
111 | 111 | | |
112 | 112 | | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
117 | 117 | | |
118 | 118 | | |
119 | 119 | | |
120 | 120 | | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
125 | 125 | | |
126 | 126 | | |
127 | 127 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
105 | 105 | | |
106 | 106 | | |
107 | 107 | | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
118 | 143 | | |
119 | 144 | | |
120 | 145 | | |
| |||
131 | 156 | | |
132 | 157 | | |
133 | 158 | | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | | - | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
142 | 184 | | |
143 | 185 | | |
144 | 186 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
84 | 84 | | |
85 | 85 | | |
86 | 86 | | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
97 | 99 | | |
98 | 100 | | |
99 | 101 | | |
| |||
181 | 183 | | |
182 | 184 | | |
183 | 185 | | |
184 | | - | |
185 | | - | |
| 186 | + | |
| 187 | + | |
186 | 188 | | |
187 | 189 | | |
188 | | - | |
189 | | - | |
190 | | - | |
191 | | - | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
192 | 194 | | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
193 | 200 | | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
194 | 210 | | |
195 | 211 | | |
196 | 212 | | |
| |||
201 | 217 | | |
202 | 218 | | |
203 | 219 | | |
204 | | - | |
205 | | - | |
206 | | - | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
207 | 227 | | |
208 | 228 | | |
209 | 229 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
460 | 460 | | |
461 | 461 | | |
462 | 462 | | |
463 | | - | |
464 | | - | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
465 | 467 | | |
466 | 468 | | |
467 | 469 | | |
| |||
678 | 680 | | |
679 | 681 | | |
680 | 682 | | |
681 | | - | |
682 | | - | |
683 | | - | |
684 | | - | |
685 | | - | |
686 | | - | |
687 | | - | |
688 | | - | |
689 | | - | |
690 | | - | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
691 | 692 | | |
692 | 693 | | |
693 | 694 | | |
| |||
1082 | 1083 | | |
1083 | 1084 | | |
1084 | 1085 | | |
1085 | | - | |
1086 | | - | |
1087 | | - | |
1088 | | - | |
1089 | | - | |
1090 | | - | |
1091 | | - | |
1092 | | - | |
1093 | | - | |
1094 | | - | |
1095 | | - | |
1096 | | - | |
1097 | | - | |
1098 | | - | |
1099 | | - | |
1100 | | - | |
1101 | | - | |
1102 | | - | |
1103 | | - | |
1104 | | - | |
1105 | | - | |
1106 | | - | |
1107 | | - | |
1108 | | - | |
| 1086 | + | |
| 1087 | + | |
| 1088 | + | |
| 1089 | + | |
| 1090 | + | |
| 1091 | + | |
| 1092 | + | |
| 1093 | + | |
| 1094 | + | |
| 1095 | + | |
| 1096 | + | |
| 1097 | + | |
| 1098 | + | |
| 1099 | + | |
| 1100 | + | |
| 1101 | + | |
| 1102 | + | |
| 1103 | + | |
| 1104 | + | |
| 1105 | + | |
| 1106 | + | |
1109 | 1107 | | |
1110 | 1108 | | |
1111 | 1109 | | |
| |||
0 commit comments