Skip to content

Commit 376b934

Browse files
committed
fixed lints
1 parent 07ca0b8 commit 376b934

File tree

18 files changed

+36
-36
lines changed

18 files changed

+36
-36
lines changed

air/src/air/assertions/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ impl<E: FieldElement> Assertion<E> {
191191
return false;
192192
}
193193
if other.is_single() || self.stride < other.stride {
194-
(other.first_step - self.first_step) % self.stride == 0
194+
(other.first_step - self.first_step).is_multiple_of(self.stride)
195195
} else {
196196
false
197197
}
@@ -200,7 +200,7 @@ impl<E: FieldElement> Assertion<E> {
200200
return false;
201201
}
202202
if self.is_single() || other.stride < self.stride {
203-
(self.first_step - other.first_step) % other.stride == 0
203+
(self.first_step - other.first_step).is_multiple_of(other.stride)
204204
} else {
205205
false
206206
}

air/src/air/divisor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ mod tests {
253253
let expected = polynom::eval(&poly, g.exp((i as u32).into()));
254254
let actual = divisor.evaluate_at(g.exp((i as u32).into()));
255255
assert_eq!(expected, actual);
256-
if i % (j as usize) == 0 {
256+
if i.is_multiple_of(j as usize) {
257257
assert_eq!(BaseElement::ZERO, actual);
258258
}
259259
}

crypto/src/hash/rescue/rp62_248/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ impl Hasher for Rp62_248 {
9898
// compute the number of elements required to represent the string; we will be processing
9999
// the string in 7-byte chunks, thus the number of elements will be equal to the number
100100
// of such chunks (including a potential partial chunk at the end).
101-
let num_elements = if bytes.len() % 7 == 0 {
101+
let num_elements = if bytes.len().is_multiple_of(7) {
102102
bytes.len() / 7
103103
} else {
104104
bytes.len() / 7 + 1
@@ -134,7 +134,7 @@ impl Hasher for Rp62_248 {
134134
// again from zero index.
135135
state[i] += BaseElement::new(u64::from_le_bytes(buf));
136136
i += 1;
137-
if i % RATE_WIDTH == 0 {
137+
if i.is_multiple_of(RATE_WIDTH) {
138138
apply_permutation(&mut state);
139139
i = 0;
140140
}
@@ -212,7 +212,7 @@ impl ElementHasher for Rp62_248 {
212212
for &element in elements.iter() {
213213
state[i] += element;
214214
i += 1;
215-
if i % RATE_WIDTH == 0 {
215+
if i.is_multiple_of(RATE_WIDTH) {
216216
apply_permutation(&mut state);
217217
i = 0;
218218
}

crypto/src/hash/rescue/rp64_256/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ impl Hasher for Rp64_256 {
124124
// compute the number of elements required to represent the string; we will be processing
125125
// the string in 7-byte chunks, thus the number of elements will be equal to the number
126126
// of such chunks (including a potential partial chunk at the end).
127-
let num_elements = if bytes.len() % 7 == 0 {
127+
let num_elements = if bytes.len().is_multiple_of(7) {
128128
bytes.len() / 7
129129
} else {
130130
bytes.len() / 7 + 1
@@ -160,7 +160,7 @@ impl Hasher for Rp64_256 {
160160
// again from zero index.
161161
state[RATE_RANGE.start + i] += BaseElement::new(u64::from_le_bytes(buf));
162162
i += 1;
163-
if i % RATE_WIDTH == 0 {
163+
if i.is_multiple_of(RATE_WIDTH) {
164164
Self::apply_permutation(&mut state);
165165
i = 0;
166166
}
@@ -238,7 +238,7 @@ impl ElementHasher for Rp64_256 {
238238
for &element in elements.iter() {
239239
state[RATE_RANGE.start + i] += element;
240240
i += 1;
241-
if i % RATE_WIDTH == 0 {
241+
if i.is_multiple_of(RATE_WIDTH) {
242242
Self::apply_permutation(&mut state);
243243
i = 0;
244244
}

crypto/src/hash/rescue/rp64_256_jive/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ impl Hasher for RpJive64_256 {
120120
// compute the number of elements required to represent the string; we will be processing
121121
// the string in 7-byte chunks, thus the number of elements will be equal to the number
122122
// of such chunks (including a potential partial chunk at the end).
123-
let num_elements = if bytes.len() % 7 == 0 {
123+
let num_elements = if bytes.len().is_multiple_of(7) {
124124
bytes.len() / 7
125125
} else {
126126
bytes.len() / 7 + 1
@@ -129,7 +129,7 @@ impl Hasher for RpJive64_256 {
129129
// initialize state to all zeros, except for the first element of the capacity part, which
130130
// is set to 1 if the number of elements is not a multiple of RATE_WIDTH.
131131
let mut state = [BaseElement::ZERO; STATE_WIDTH];
132-
if num_elements % RATE_WIDTH != 0 {
132+
if !num_elements.is_multiple_of(RATE_WIDTH) {
133133
state[CAPACITY_RANGE.start] = BaseElement::ONE;
134134
}
135135

@@ -157,7 +157,7 @@ impl Hasher for RpJive64_256 {
157157
// absorbing again from zero index.
158158
state[RATE_RANGE.start + i] += BaseElement::new(u64::from_le_bytes(buf));
159159
i += 1;
160-
if i % RATE_WIDTH == 0 {
160+
if i.is_multiple_of(RATE_WIDTH) {
161161
Self::apply_permutation(&mut state);
162162
i = 0;
163163
}
@@ -236,7 +236,7 @@ impl ElementHasher for RpJive64_256 {
236236
// initialize state to all zeros, except for the first element of the capacity part, which
237237
// is set to 1 if the number of elements is not a multiple of RATE_WIDTH.
238238
let mut state = [BaseElement::ZERO; STATE_WIDTH];
239-
if elements.len() % RATE_WIDTH != 0 {
239+
if !elements.len().is_multiple_of(RATE_WIDTH) {
240240
state[CAPACITY_RANGE.start] = BaseElement::ONE;
241241
}
242242

@@ -247,7 +247,7 @@ impl ElementHasher for RpJive64_256 {
247247
for &element in elements.iter() {
248248
state[RATE_RANGE.start + i] += element;
249249
i += 1;
250-
if i % RATE_WIDTH == 0 {
250+
if i.is_multiple_of(RATE_WIDTH) {
251251
Self::apply_permutation(&mut state);
252252
i = 0;
253253
}

examples/src/lamport/aggregate/air.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ impl Air for LamportAggregateAir {
181181
for (i, value) in powers_of_two.iter_mut().enumerate().skip(1) {
182182
// we switch to a new power of two once every 8 steps this. is so that a
183183
// new power of two is available for every hash cycle
184-
if i % HASH_CYCLE_LEN == 0 {
184+
if i.is_multiple_of(HASH_CYCLE_LEN) {
185185
current_power_of_two *= TWO;
186186
}
187187
*value = current_power_of_two;

examples/src/lamport/threshold/air.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ impl Air for LamportThresholdAir {
216216
for (i, value) in powers_of_two.iter_mut().enumerate().skip(1) {
217217
// we switch to a new power of two once every 8 steps this. is so that a
218218
// new power of two is available for every hash cycle
219-
if i % HASH_CYCLE_LEN == 0 {
219+
if i.is_multiple_of(HASH_CYCLE_LEN) {
220220
current_power_of_two *= TWO;
221221
}
222222
*value = current_power_of_two;

examples/src/utils/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ pub fn print_trace<E: StarkField>(
6969

7070
let mut state = vec![E::ZERO; trace_width];
7171
for i in 0..trace.length() {
72-
if (i.wrapping_sub(offset)) % multiples_of != 0 {
72+
if !(i.wrapping_sub(offset)).is_multiple_of(multiples_of) {
7373
continue;
7474
}
7575
trace.read_row_into(i, &mut state);

examples/src/utils/rescue.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ impl Rescue128 {
6161
for &element in data {
6262
self.state[self.idx] += element;
6363
self.idx += 1;
64-
if self.idx % RATE_WIDTH == 0 {
64+
if self.idx.is_multiple_of(RATE_WIDTH) {
6565
apply_permutation(&mut self.state);
6666
self.idx = 0;
6767
}
@@ -86,7 +86,7 @@ impl Rescue128 {
8686
for &element in data.iter() {
8787
state[i] += element;
8888
i += 1;
89-
if i % RATE_WIDTH == 0 {
89+
if i.is_multiple_of(RATE_WIDTH) {
9090
apply_permutation(&mut state);
9191
i = 0;
9292
}

fri/src/proof.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ impl FriProofLayer {
298298
{
299299
// make sure the number of value bytes can be parsed into a whole number of queries
300300
let num_query_bytes = E::ELEMENT_BYTES * folding_factor;
301-
if self.values.len() % num_query_bytes != 0 {
301+
if !self.values.len().is_multiple_of(num_query_bytes) {
302302
return Err(DeserializationError::InvalidValue(format!(
303303
"number of value bytes ({}) does not divide into whole number of queries",
304304
self.values.len(),

0 commit comments

Comments
 (0)