Skip to content

Fix latest clippy #1676

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion plonky2/src/gates/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ impl<'a, P: PackedField> StridedConstraintConsumer<'a, P> {

/// Emit one constraint.
pub fn one(&mut self, constraint: P) {
if self.start != self.end {
if !core::ptr::eq(self.start, self.end) {
// # Safety
// The checks in `new` guarantee that this points to valid space.
unsafe {
Expand Down
37 changes: 0 additions & 37 deletions plonky2/src/hash/arch/aarch64/poseidon_goldilocks_neon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,23 +54,6 @@ const fn check_mds_matrix() -> bool {
}
const_assert!(check_mds_matrix());

/// Ensure that the first WIDTH round constants are in canonical* form. This is required because
/// the first constant layer does not handle double overflow.
/// *: round_const == GoldilocksField::ORDER is safe.
/*
#[allow(dead_code)]
const fn check_round_const_bounds_init() -> bool {
let mut i = 0;
while i < WIDTH {
if ALL_ROUND_CONSTANTS[i] > GoldilocksField::ORDER {
return false;
}
i += 1;
}
true
}
const_assert!(check_round_const_bounds_init());
*/
// ====================================== SCALAR ARITHMETIC =======================================

/// Addition modulo ORDER accounting for wraparound. Correct only when a + b < 2**64 + ORDER.
Expand Down Expand Up @@ -149,26 +132,6 @@ unsafe fn multiply(x: u64, y: u64) -> u64 {
add_with_wraparound(res0, xy_hi_lo_mul_epsilon)
}

// ==================================== STANDALONE CONST LAYER =====================================

/// Standalone const layer. Run only once, at the start of round 1. Remaining const layers are fused
/// with the preceding MDS matrix multiplication.
/*
#[inline(always)]
#[unroll_for_loops]
unsafe fn const_layer_full(
mut state: [u64; WIDTH],
round_constants: &[u64; WIDTH],
) -> [u64; WIDTH] {
assert!(WIDTH == 12);
for i in 0..12 {
let rc = round_constants[i];
// add_with_wraparound is safe, because rc is in canonical form.
state[i] = add_with_wraparound(state[i], rc);
}
state
}
*/
// ========================================== FULL ROUNDS ==========================================

/// Full S-box.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(clippy::assertions_on_constants)]

use core::arch::asm;
use core::arch::x86_64::*;
use core::mem::size_of;
Expand Down
4 changes: 2 additions & 2 deletions plonky2/src/util/strided_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ impl<'a, P: PackedField> Iterator for PackedStridedViewIter<'a, P> {
"start and end pointers should be separated by a multiple of stride"
);

if self.start != self.end {
if !core::ptr::eq(self.start, self.end) {
let res = unsafe { &*self.start.cast() };
// See comment in `PackedStridedView`. Below will point more than one byte past the end
// of the buffer if the offset is not 0 and we've reached the end.
Expand All @@ -224,7 +224,7 @@ impl<P: PackedField> DoubleEndedIterator for PackedStridedViewIter<'_, P> {
"start and end pointers should be separated by a multiple of stride"
);

if self.start != self.end {
if !core::ptr::eq(self.start, self.end) {
// See comment in `PackedStridedView`. `self.end` starts off pointing more than one byte
// past the end of the buffer unless `offset` is 0.
self.end = self.end.wrapping_sub(self.stride);
Expand Down
Loading