From ef16eea85a1416a593acae018abb1aa57c68794a Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Tue, 7 May 2024 17:10:45 +0000 Subject: [PATCH] Make crypto/ clippy-clean, mostly by telling clippy to shut up --- src/crypto/bigint.rs | 7 ++++++- src/crypto/ec.rs | 4 +--- src/http.rs | 6 ++++++ src/lib.rs | 6 ++++++ 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/crypto/bigint.rs b/src/crypto/bigint.rs index a9245a4..eec0a56 100644 --- a/src/crypto/bigint.rs +++ b/src/crypto/bigint.rs @@ -3,6 +3,11 @@ use alloc::vec::Vec; use core::marker::PhantomData; +#[allow(clippy::needless_lifetimes)] // lifetimes improve readability +#[allow(clippy::needless_borrow)] // borrows indicate read-only/non-move +#[allow(clippy::too_many_arguments)] // sometimes we don't have an option +#[allow(clippy::identity_op)] // sometimes identities improve readability for repeated actions + // ************************************** // * Implementations of math primitives * // ************************************** @@ -698,7 +703,7 @@ impl U4096 { if self > m { return Err(()); } let mut t = [0; WORD_COUNT_4096]; - if &m.0[..WORD_COUNT_4096 - 1] == &[0; WORD_COUNT_4096 - 1] && m.0[WORD_COUNT_4096 - 1] == 1 { + if m.0[..WORD_COUNT_4096 - 1] == [0; WORD_COUNT_4096 - 1] && m.0[WORD_COUNT_4096 - 1] == 1 { return Ok(U4096(t)); } t[WORD_COUNT_4096 - 1] = 1; diff --git a/src/crypto/ec.rs b/src/crypto/ec.rs index bd8c5cf..7562deb 100644 --- a/src/crypto/ec.rs +++ b/src/crypto/ec.rs @@ -142,9 +142,7 @@ impl Point { let e: C::IntModP = C::IntModP::from_i(expected_x.clone().into_i()); if self.z == C::IntModP::ZERO { return Err(()); } let ezz = e.mul(&self.z).mul(&self.z); - if self.x == ezz { Ok(()) } else { - if slow_check == Some(true) { Ok(()) } else { Err(()) } - } + if self.x == ezz || slow_check == Some(true) { Ok(()) } else { Err(()) } } fn double(&self) -> Result { diff --git a/src/http.rs b/src/http.rs index 76c54c1..0656c4c 100644 --- a/src/http.rs +++ b/src/http.rs @@ -6,6 +6,12 @@ // Luckily, it seems to work fine in 1.63 with the feature flag (and RUSTC_BOOTSTRAP=1) enabled. #![cfg_attr(all(feature = "validation", rust_1_63), feature(const_slice_from_raw_parts))] +#![allow(clippy::needless_lifetimes)] // lifetimes improve readability +#![allow(clippy::needless_borrow)] // borrows indicate read-only/non-move +#![allow(clippy::too_many_arguments)] // sometimes we don't have an option +#![allow(clippy::identity_op)] // sometimes identities improve readability for repeated actions +#![allow(clippy::erasing_op)] // sometimes identities improve readability for repeated actions + extern crate alloc; pub mod rr; diff --git a/src/lib.rs b/src/lib.rs index 77c3cd9..c402a72 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -37,6 +37,12 @@ // Luckily, it seems to work fine in 1.63 with the feature flag (and RUSTC_BOOTSTRAP=1) enabled. #![cfg_attr(rust_1_63, feature(const_slice_from_raw_parts))] +#![allow(clippy::needless_lifetimes)] // lifetimes improve readability +#![allow(clippy::needless_borrow)] // borrows indicate read-only/non-move +#![allow(clippy::too_many_arguments)] // sometimes we don't have an option +#![allow(clippy::identity_op)] // sometimes identities improve readability for repeated actions +#![allow(clippy::erasing_op)] // sometimes identities improve readability for repeated actions + #![cfg_attr(not(feature = "std"), no_std)] extern crate alloc; -- 2.39.5