Skip to content

Commit cd12b4c

Browse files
committed
clippy
1 parent df78473 commit cd12b4c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+907
-814
lines changed

Cargo.toml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ resolver = "3"
2525

2626
[workspace.lints]
2727
rust.missing_debug_implementations = "warn"
28-
rust.unreachable_pub = "warn"
2928
rust.unused_must_use = "deny"
3029
rust.rust_2018_idioms = { level = "deny", priority = -1 }
3130
rust.dead_code = "allow"
@@ -35,7 +34,6 @@ rustdoc.all = "warn"
3534
all = { level = "warn", priority = -1 }
3635
nursery = { level = "warn", priority = -1 }
3736
doc_markdown = "allow"
38-
pedantic = { level = "warn", priority = -1 }
3937
cast_possible_truncation = "allow"
4038
cast_precision_loss = "allow"
4139
missing_errors_doc = "allow"
@@ -45,6 +43,20 @@ should_panic_without_expect = "allow"
4543
similar_names = "allow"
4644
suboptimal_flops = "allow"
4745
cast_sign_loss = "allow"
46+
redundant_pub_crate = "allow"
47+
too_many_lines = "allow"
48+
to_string_trait_impl = "allow"
49+
transmute_ptr_to_ptr = "allow"
50+
missing_transmute_annotations = "allow"
51+
type_complexity = "allow"
52+
needless_range_loop = "allow"
53+
too_many_arguments = "allow"
54+
result_large_err = "allow"
55+
format_push_string = "allow"
56+
option_if_let_else = "allow"
57+
mismatching_type_param_order = "allow"
58+
cognitive_complexity = "allow"
59+
large_enum_variant = "allow"
4860

4961
[workspace.dependencies]
5062
lean-isa = { path = "crates/leanIsa" }

crates/air/src/prove.rs

Lines changed: 34 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -76,21 +76,21 @@ pub fn prove_many_air_3<
7676
"TODO handle the case UNIVARIATE_SKIPS >= log_length"
7777
);
7878
}
79-
for i in 0..tables_2.len() {
79+
for witness in witnesses_2.iter().take(tables_2.len()) {
8080
assert!(
81-
univariate_skips < witnesses_2[i].log_n_rows(),
81+
univariate_skips < witness.log_n_rows(),
8282
"TODO handle the case UNIVARIATE_SKIPS >= log_length"
8383
);
8484
}
85-
for i in 0..tables_3.len() {
85+
for witness in witnesses_3.iter().take(tables_3.len()) {
8686
assert!(
87-
univariate_skips < witnesses_3[i].log_n_rows(),
87+
univariate_skips < witness.log_n_rows(),
8888
"TODO handle the case UNIVARIATE_SKIPS >= log_length"
8989
);
9090
}
91-
let structured_air = if tables_1.len() > 0 {
91+
let structured_air = if !tables_1.is_empty() {
9292
tables_1[0].air.structured()
93-
} else if tables_2.len() > 0 {
93+
} else if !tables_2.is_empty() {
9494
tables_2[0].air.structured()
9595
} else {
9696
tables_3[0].air.structured()
@@ -113,15 +113,15 @@ pub fn prove_many_air_3<
113113

114114
let log_lengths_1 = witnesses_1
115115
.iter()
116-
.map(|w| w.log_n_rows())
116+
.map(super::witness::AirWitness::log_n_rows)
117117
.collect::<Vec<_>>();
118118
let log_lengths_2 = witnesses_2
119119
.iter()
120-
.map(|w| w.log_n_rows())
120+
.map(super::witness::AirWitness::log_n_rows)
121121
.collect::<Vec<_>>();
122122
let log_lengths_3 = witnesses_3
123123
.iter()
124-
.map(|w| w.log_n_rows())
124+
.map(super::witness::AirWitness::log_n_rows)
125125
.collect::<Vec<_>>();
126126

127127
let max_n_constraints = Iterator::max(
@@ -186,10 +186,10 @@ pub fn prove_many_air_3<
186186
sumcheck::prove_in_parallel_3::<EF, _, _, _, _>(
187187
vec![univariate_skips; n_tables],
188188
columns_for_zero_check_packed,
189-
tables_1.iter().map(|t| &t.air).collect::<Vec<_>>(),
190-
tables_2.iter().map(|t| &t.air).collect::<Vec<_>>(),
191-
tables_3.iter().map(|t| &t.air).collect::<Vec<_>>(),
192-
vec![&constraints_batching_scalars; n_tables],
189+
&tables_1.iter().map(|t| &t.air).collect::<Vec<_>>(),
190+
&tables_2.iter().map(|t| &t.air).collect::<Vec<_>>(),
191+
&tables_3.iter().map(|t| &t.air).collect::<Vec<_>>(),
192+
&vec![constraints_batching_scalars.as_slice(); n_tables],
193193
all_zerocheck_challenges,
194194
vec![true; n_tables],
195195
prover_state,
@@ -237,11 +237,11 @@ pub fn prove_many_air_3<
237237

238238
impl<EF: ExtensionField<PF<EF>>, A: MyAir<EF>> AirTable<EF, A> {
239239
#[instrument(name = "air: prove base", skip_all)]
240-
pub fn prove_base<'a>(
240+
pub fn prove_base(
241241
&self,
242242
prover_state: &mut FSProver<EF, impl FSChallenger<EF>>,
243243
univariate_skips: usize,
244-
witness: AirWitness<'a, PF<EF>>,
244+
witness: AirWitness<'_, PF<EF>>,
245245
) -> Vec<Evaluation<EF>> {
246246
let mut res = prove_many_air_3::<EF, A, A, A>(
247247
prover_state,
@@ -258,11 +258,11 @@ impl<EF: ExtensionField<PF<EF>>, A: MyAir<EF>> AirTable<EF, A> {
258258
}
259259

260260
#[instrument(name = "air: prove base", skip_all)]
261-
pub fn prove_extension<'a>(
261+
pub fn prove_extension(
262262
&self,
263263
prover_state: &mut FSProver<EF, impl FSChallenger<EF>>,
264264
univariate_skips: usize,
265-
witness: AirWitness<'a, EF>,
265+
witness: AirWitness<'_, EF>,
266266
) -> Vec<Evaluation<EF>> {
267267
let mut res = prove_many_air_3::<EF, A, A, A>(
268268
prover_state,
@@ -290,8 +290,8 @@ fn eval_unstructured_column_groups<EF: ExtensionField<PF<EF>> + ExtensionField<I
290290
for group in &witnesses.column_groups {
291291
let batched_column = multilinears_linear_combination(
292292
&witnesses.cols[group.clone()],
293-
&eval_eq(&from_end(
294-
&columns_batching_scalars,
293+
&eval_eq(from_end(
294+
columns_batching_scalars,
295295
log2_ceil_usize(group.len()),
296296
))[..group.len()],
297297
);
@@ -300,7 +300,7 @@ fn eval_unstructured_column_groups<EF: ExtensionField<PF<EF>> + ExtensionField<I
300300
let sub_evals = fold_multilinear(
301301
&batched_column,
302302
&MultilinearPoint(
303-
outer_sumcheck_challenge[1..witnesses.log_n_rows() - univariate_skips + 1].to_vec(),
303+
outer_sumcheck_challenge[1..=(witnesses.log_n_rows() - univariate_skips)].to_vec(),
304304
),
305305
);
306306

@@ -323,8 +323,12 @@ fn open_unstructured_columns<'a, EF: ExtensionField<PF<EF>>>(
323323
witnesses_1
324324
.iter()
325325
.chain(witnesses_2)
326-
.map(|w| w.max_columns_per_group())
327-
.chain(witnesses_3.iter().map(|w| w.max_columns_per_group())),
326+
.map(super::witness::AirWitness::max_columns_per_group)
327+
.chain(
328+
witnesses_3
329+
.iter()
330+
.map(super::witness::AirWitness::max_columns_per_group),
331+
),
328332
)
329333
.unwrap();
330334
let columns_batching_scalars = prover_state.sample_vec(log2_ceil_usize(max_columns_per_group));
@@ -374,7 +378,7 @@ fn open_unstructured_columns<'a, EF: ExtensionField<PF<EF>>>(
374378
[
375379
from_end(&columns_batching_scalars, log2_ceil_usize(group.len())).to_vec(),
376380
epsilons.0.clone(),
377-
outer_sumcheck_challenge[1..log_n_rows - univariate_skips + 1].to_vec(),
381+
outer_sumcheck_challenge[1..=(log_n_rows - univariate_skips)].to_vec(),
378382
]
379383
.concat(),
380384
),
@@ -387,10 +391,10 @@ fn open_unstructured_columns<'a, EF: ExtensionField<PF<EF>>>(
387391
}
388392

389393
#[instrument(skip_all)]
390-
fn open_structured_columns<'a, EF: ExtensionField<PF<EF>> + ExtensionField<IF>, IF: Field>(
394+
fn open_structured_columns<EF: ExtensionField<PF<EF>> + ExtensionField<IF>, IF: Field>(
391395
prover_state: &mut FSProver<EF, impl FSChallenger<EF>>,
392396
univariate_skips: usize,
393-
witness: &AirWitness<'a, IF>,
397+
witness: &AirWitness<'_, IF>,
394398
outer_sumcheck_challenge: &[EF],
395399
) -> Vec<Evaluation<EF>> {
396400
let columns_batching_scalars = prover_state.sample_vec(witness.log_max_columns_per_group());
@@ -403,7 +407,7 @@ fn open_structured_columns<'a, EF: ExtensionField<PF<EF>> + ExtensionField<IF>,
403407
for group in &witness.column_groups {
404408
let batched_column = multilinears_linear_combination(
405409
&witness.cols[group.clone()],
406-
&eval_eq(&from_end(
410+
&eval_eq(from_end(
407411
&columns_batching_scalars,
408412
log2_ceil_usize(group.len()),
409413
))[..group.len()],
@@ -419,7 +423,7 @@ fn open_structured_columns<'a, EF: ExtensionField<PF<EF>> + ExtensionField<IF>,
419423
let sub_evals = fold_multilinear(
420424
&batched_column_mixed,
421425
&MultilinearPoint(
422-
outer_sumcheck_challenge[1..witness.log_n_rows() - univariate_skips + 1].to_vec(),
426+
outer_sumcheck_challenge[1..=(witness.log_n_rows() - univariate_skips)].to_vec(),
423427
),
424428
);
425429

@@ -434,7 +438,7 @@ fn open_structured_columns<'a, EF: ExtensionField<PF<EF>> + ExtensionField<IF>,
434438
{
435439
let point = [
436440
epsilons.clone(),
437-
outer_sumcheck_challenge[1..witness.log_n_rows() - univariate_skips + 1].to_vec(),
441+
outer_sumcheck_challenge[1..=(witness.log_n_rows() - univariate_skips)].to_vec(),
438442
]
439443
.concat();
440444
let mles_for_inner_sumcheck = vec![
@@ -456,8 +460,8 @@ fn open_structured_columns<'a, EF: ExtensionField<PF<EF>> + ExtensionField<IF>,
456460
let (inner_challenges, all_inner_evals, _) = sumcheck::prove_in_parallel_1::<EF, _, _>(
457461
vec![1; n_groups],
458462
all_inner_mles,
459-
vec![&ProductComputation; n_groups],
460-
vec![&[]; n_groups],
463+
&vec![&ProductComputation; n_groups],
464+
&vec![[].as_slice(); n_groups],
461465
vec![None; n_groups],
462466
vec![false; n_groups],
463467
prover_state,

crates/air/src/table.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,12 @@ impl<EF: ExtensionField<PF<EF>>, A: MyAir<EF>> AirTable<EF, A> {
1919
pub fn new(air: A) -> Self {
2020
let symbolic_constraints = get_symbolic_constraints(&air, 0, 0);
2121
let n_constraints = symbolic_constraints.len();
22-
let constraint_degree =
23-
Iterator::max(symbolic_constraints.iter().map(|c| c.degree_multiple())).unwrap();
22+
let constraint_degree = Iterator::max(
23+
symbolic_constraints
24+
.iter()
25+
.map(p3_uni_stark::SymbolicExpression::degree_multiple),
26+
)
27+
.unwrap();
2428
assert_eq!(constraint_degree, air.degree());
2529
Self {
2630
air,
@@ -42,17 +46,17 @@ impl<EF: ExtensionField<PF<EF>>, A: MyAir<EF>> AirTable<EF, A> {
4246
EF: ExtensionField<IF>,
4347
{
4448
if witness.n_columns() != self.n_columns() {
45-
return Err(format!("Invalid number of columns",));
49+
return Err("Invalid number of columns".to_string());
4650
}
4751
let handle_errors = |row: usize, constraint_checker: &mut ConstraintChecker<'_, IF, EF>| {
48-
if constraint_checker.errors.len() > 0 {
52+
if !constraint_checker.errors.is_empty() {
4953
return Err(format!(
5054
"Trace is not valid at row {}: contraints not respected: {}",
5155
row,
5256
constraint_checker
5357
.errors
5458
.iter()
55-
.map(|e| e.to_string())
59+
.map(std::string::ToString::to_string)
5660
.collect::<Vec<_>>()
5761
.join(", ")
5862
));

crates/air/src/test.rs

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
use std::borrow::Borrow;
22

33
use p3_air::{Air, AirBuilder, BaseAir};
4-
use p3_field::PrimeCharacteristicRing;
5-
use p3_field::extension::BinomialExtensionField;
4+
use p3_field::{PrimeCharacteristicRing, extension::BinomialExtensionField};
65
use p3_koala_bear::KoalaBear;
76
use p3_matrix::Matrix;
87
use rand::{Rng, SeedableRng, rngs::StdRng};
@@ -107,9 +106,13 @@ fn generate_structured_trace<const N_COLUMNS: usize, const N_PREPROCESSED_COLUMN
107106
}
108107
let mut witness_cols = vec![vec![F::ZERO]; N_COLUMNS - N_PREPROCESSED_COLUMNS];
109108
for i in 1..n_rows {
110-
for j in 0..N_COLUMNS - N_PREPROCESSED_COLUMNS {
111-
let witness_cols_j_i_min_1 = witness_cols[j][i - 1];
112-
witness_cols[j].push(
109+
for (j, witness_col) in witness_cols
110+
.iter_mut()
111+
.enumerate()
112+
.take(N_COLUMNS - N_PREPROCESSED_COLUMNS)
113+
{
114+
let witness_cols_j_i_min_1 = witness_col[i - 1];
115+
witness_col.push(
113116
witness_cols_j_i_min_1
114117
+ F::from_usize(j + N_PREPROCESSED_COLUMNS)
115118
+ (0..N_PREPROCESSED_COLUMNS)
@@ -133,8 +136,12 @@ fn generate_unstructured_trace<const N_COLUMNS: usize, const N_PREPROCESSED_COLU
133136
}
134137
let mut witness_cols = vec![vec![]; N_COLUMNS - N_PREPROCESSED_COLUMNS];
135138
for i in 0..n_rows {
136-
for j in 0..N_COLUMNS - N_PREPROCESSED_COLUMNS {
137-
witness_cols[j].push(
139+
for (j, witness_col) in witness_cols
140+
.iter_mut()
141+
.enumerate()
142+
.take(N_COLUMNS - N_PREPROCESSED_COLUMNS)
143+
{
144+
witness_col.push(
138145
F::from_usize(j + N_PREPROCESSED_COLUMNS)
139146
+ (0..N_PREPROCESSED_COLUMNS)
140147
.map(|k| trace[k][i])
@@ -227,6 +234,7 @@ fn test_unstructured_air() {
227234
}
228235

229236
#[test]
237+
#[allow(clippy::too_many_lines)]
230238
fn test_many_unstructured_air() {
231239
const N_COLUMNS_A: usize = 10;
232240
const N_PREPROCESSED_COLUMNS_A: usize = 3;
@@ -347,6 +355,7 @@ fn test_many_unstructured_air() {
347355
}
348356

349357
#[test]
358+
#[allow(clippy::too_many_lines)]
350359
fn test_many_structured_air() {
351360
const N_COLUMNS_A: usize = 10;
352361
const N_PREPROCESSED_COLUMNS_A: usize = 3;

crates/air/src/uni_skip_utils.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use tracing::instrument;
33
use whir_p3::poly::evals::{eval_eq, scale_poly};
44

55
#[instrument(name = "matrix_up_folded", skip_all)]
6-
pub(crate) fn matrix_up_folded<F: Field>(outer_challenges: &[F]) -> Vec<F> {
6+
pub fn matrix_up_folded<F: Field>(outer_challenges: &[F]) -> Vec<F> {
77
let n = outer_challenges.len();
88
let mut folded = eval_eq(outer_challenges);
99
let outer_challenges_prod: F = outer_challenges.iter().copied().product();
@@ -13,7 +13,7 @@ pub(crate) fn matrix_up_folded<F: Field>(outer_challenges: &[F]) -> Vec<F> {
1313
}
1414

1515
#[instrument(name = "matrix_down_folded", skip_all)]
16-
pub(crate) fn matrix_down_folded<F: Field>(outer_challenges: &[F]) -> Vec<F> {
16+
pub fn matrix_down_folded<F: Field>(outer_challenges: &[F]) -> Vec<F> {
1717
let n = outer_challenges.len();
1818
let mut folded = vec![F::ZERO; 1 << n];
1919
for k in 0..n {

crates/air/src/utils.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use p3_field::Field;
22
use rayon::prelude::*;
33
use whir_p3::poly::multilinear::MultilinearPoint;
44

5-
pub(crate) fn matrix_up_lde<F: Field>(point: &[F]) -> F {
5+
pub fn matrix_up_lde<F: Field>(point: &[F]) -> F {
66
/*
77
Matrix UP:
88
@@ -29,7 +29,7 @@ pub(crate) fn matrix_up_lde<F: Field>(point: &[F]) -> F {
2929
* (F::ONE - point[point.len() - 1] * F::TWO)
3030
}
3131

32-
pub(crate) fn matrix_down_lde<F: Field>(point: &[F]) -> F {
32+
pub fn matrix_down_lde<F: Field>(point: &[F]) -> F {
3333
/*
3434
Matrix DOWN:
3535
@@ -130,21 +130,21 @@ fn next_mle<F: Field>(point: &[F]) -> F {
130130
.sum()
131131
}
132132

133-
pub(crate) fn columns_up_and_down<F: Field>(columns: &[&[F]]) -> Vec<Vec<F>> {
133+
pub fn columns_up_and_down<F: Field>(columns: &[&[F]]) -> Vec<Vec<F>> {
134134
columns
135135
.par_iter()
136136
.map(|c| column_up(c))
137137
.chain(columns.par_iter().map(|c| column_down(c)))
138138
.collect()
139139
}
140140

141-
pub(crate) fn column_up<F: Field>(column: &[F]) -> Vec<F> {
141+
pub fn column_up<F: Field>(column: &[F]) -> Vec<F> {
142142
let mut up = column.to_vec();
143143
up[column.len() - 1] = up[column.len() - 2];
144144
up
145145
}
146146

147-
pub(crate) fn column_down<F: Field>(column: &[F]) -> Vec<F> {
147+
pub fn column_down<F: Field>(column: &[F]) -> Vec<F> {
148148
let mut down = column[1..].to_vec();
149149
down.push(*down.last().unwrap());
150150
down

0 commit comments

Comments
 (0)