Skip to content

Commit 6caf9af

Browse files
authored
apply nightly clippy fixes: const div_ceil (2025-05-12) (#968)
1 parent c1f1829 commit 6caf9af

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

slh-dsa/src/hashes/sha2.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ impl HypertreeParams for Sha2_128s {
166166
impl ForsParams for Sha2_128s {
167167
type K = U<14>;
168168
type A = U<12>;
169-
type MD = U<{ (12 * 14 + 7) / 8 }>;
169+
type MD = U<{ (12 * 14usize).div_ceil(8) }>;
170170
}
171171
impl ParameterSet for Sha2_128s {
172172
const NAME: &'static str = "SLH-DSA-SHA2-128s";
@@ -329,7 +329,7 @@ impl HypertreeParams for Sha2_192s {
329329
impl ForsParams for Sha2_192s {
330330
type K = U<17>;
331331
type A = U<14>;
332-
type MD = U<{ (14 * 17 + 7) / 8 }>;
332+
type MD = U<{ (14 * 17usize).div_ceil(8) }>;
333333
}
334334
impl ParameterSet for Sha2_192s {
335335
const NAME: &'static str = "SLH-DSA-SHA2-192s";
@@ -352,7 +352,7 @@ impl HypertreeParams for Sha2_192f {
352352
impl ForsParams for Sha2_192f {
353353
type K = U<33>;
354354
type A = U<8>;
355-
type MD = U<{ (33 * 8 + 7) / 8 }>;
355+
type MD = U<{ (33 * 8usize).div_ceil(8) }>;
356356
}
357357
impl ParameterSet for Sha2_192f {
358358
const NAME: &'static str = "SLH-DSA-SHA2-192f";
@@ -375,7 +375,7 @@ impl HypertreeParams for Sha2_256s {
375375
impl ForsParams for Sha2_256s {
376376
type K = U<22>;
377377
type A = U<14>;
378-
type MD = U<{ (14 * 22 + 7) / 8 }>;
378+
type MD = U<{ (14 * 22usize).div_ceil(8) }>;
379379
}
380380
impl ParameterSet for Sha2_256s {
381381
const NAME: &'static str = "SLH-DSA-SHA2-256s";
@@ -398,7 +398,7 @@ impl HypertreeParams for Sha2_256f {
398398
impl ForsParams for Sha2_256f {
399399
type K = U<35>;
400400
type A = U<9>;
401-
type MD = U<{ (35 * 9 + 7) / 8 }>;
401+
type MD = U<{ (35 * 9usize).div_ceil(8) }>;
402402
}
403403
impl ParameterSet for Sha2_256f {
404404
const NAME: &'static str = "SLH-DSA-SHA2-256f";

slh-dsa/src/hashes/shake.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ impl HypertreeParams for Shake128s {
143143
impl ForsParams for Shake128s {
144144
type K = U<14>;
145145
type A = U<12>;
146-
type MD = U<{ (12 * 14 + 7) / 8 }>;
146+
type MD = U<{ (12 * 14usize).div_ceil(8) }>;
147147
}
148148
impl ParameterSet for Shake128s {
149149
const NAME: &'static str = "SLH-DSA-SHAKE-128s";
@@ -189,7 +189,7 @@ impl HypertreeParams for Shake192s {
189189
impl ForsParams for Shake192s {
190190
type K = U<17>;
191191
type A = U<14>;
192-
type MD = U<{ (14 * 17 + 7) / 8 }>;
192+
type MD = U<{ (14 * 17usize).div_ceil(8) }>;
193193
}
194194
impl ParameterSet for Shake192s {
195195
const NAME: &'static str = "SLH-DSA-SHAKE-192s";
@@ -212,7 +212,7 @@ impl HypertreeParams for Shake192f {
212212
impl ForsParams for Shake192f {
213213
type K = U<33>;
214214
type A = U<8>;
215-
type MD = U<{ (33 * 8 + 7) / 8 }>;
215+
type MD = U<{ (33 * 8usize).div_ceil(8) }>;
216216
}
217217
impl ParameterSet for Shake192f {
218218
const NAME: &'static str = "SLH-DSA-SHAKE-192f";
@@ -235,7 +235,7 @@ impl HypertreeParams for Shake256s {
235235
impl ForsParams for Shake256s {
236236
type K = U<22>;
237237
type A = U<14>;
238-
type MD = U<{ (14 * 22 + 7) / 8 }>;
238+
type MD = U<{ (14 * 22usize).div_ceil(8) }>;
239239
}
240240
impl ParameterSet for Shake256s {
241241
const NAME: &'static str = "SLH-DSA-SHAKE-256s";
@@ -258,7 +258,7 @@ impl HypertreeParams for Shake256f {
258258
impl ForsParams for Shake256f {
259259
type K = U<35>;
260260
type A = U<9>;
261-
type MD = U<{ (35 * 9 + 7) / 8 }>;
261+
type MD = U<{ (35 * 9usize).div_ceil(8) }>;
262262
}
263263
impl ParameterSet for Shake256f {
264264
const NAME: &'static str = "SLH-DSA-SHAKE-256f";

slh-dsa/src/util.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use hybrid_array::{Array, ArraySize, typenum::Unsigned};
33

44
// Algorithm 3
55
pub fn base_2b<OutLen: ArraySize, B: Unsigned>(x: &[u8]) -> Array<u16, OutLen> {
6-
debug_assert!(x.len() >= (OutLen::USIZE * B::USIZE + 7) / 8);
6+
debug_assert!(x.len() >= (OutLen::USIZE * B::USIZE).div_ceil(8));
77
debug_assert!(B::USIZE <= 16);
88

99
let mut bits = 0usize;

0 commit comments

Comments
 (0)