CI: bump clippy to Rust 1.87 (#768)

* CI: bump `clippy` to Rust 1.87

Performs a `cargo clippy --fix`

* ed25519: fix warning

* Rename solitary `'b` lifetimes to `'a`
This commit is contained in:
Tony Arcieri 2025-06-06 10:30:32 -06:00 committed by GitHub
parent 5e0b429b05
commit ad4a37df53
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 71 additions and 71 deletions

View file

@ -85,7 +85,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@1.81.0
- uses: dtolnay/rust-toolchain@1.87.0
with:
components: clippy
- run: cargo clippy --target x86_64-unknown-linux-gnu --all-features

View file

@ -408,10 +408,10 @@ impl ProjectivePoint {
//
// upstream rust issue: https://github.com/rust-lang/rust/issues/46380
//#[doc(hidden)]
impl<'a, 'b> Add<&'b ProjectiveNielsPoint> for &'a EdwardsPoint {
impl<'a> Add<&'a ProjectiveNielsPoint> for &EdwardsPoint {
type Output = CompletedPoint;
fn add(self, other: &'b ProjectiveNielsPoint) -> CompletedPoint {
fn add(self, other: &'a ProjectiveNielsPoint) -> CompletedPoint {
let Y_plus_X = &self.Y + &self.X;
let Y_minus_X = &self.Y - &self.X;
let PP = &Y_plus_X * &other.Y_plus_X;
@ -430,10 +430,10 @@ impl<'a, 'b> Add<&'b ProjectiveNielsPoint> for &'a EdwardsPoint {
}
//#[doc(hidden)]
impl<'a, 'b> Sub<&'b ProjectiveNielsPoint> for &'a EdwardsPoint {
impl<'a> Sub<&'a ProjectiveNielsPoint> for &EdwardsPoint {
type Output = CompletedPoint;
fn sub(self, other: &'b ProjectiveNielsPoint) -> CompletedPoint {
fn sub(self, other: &'a ProjectiveNielsPoint) -> CompletedPoint {
let Y_plus_X = &self.Y + &self.X;
let Y_minus_X = &self.Y - &self.X;
let PM = &Y_plus_X * &other.Y_minus_X;
@ -452,10 +452,10 @@ impl<'a, 'b> Sub<&'b ProjectiveNielsPoint> for &'a EdwardsPoint {
}
//#[doc(hidden)]
impl<'a, 'b> Add<&'b AffineNielsPoint> for &'a EdwardsPoint {
impl<'a> Add<&'a AffineNielsPoint> for &EdwardsPoint {
type Output = CompletedPoint;
fn add(self, other: &'b AffineNielsPoint) -> CompletedPoint {
fn add(self, other: &'a AffineNielsPoint) -> CompletedPoint {
let Y_plus_X = &self.Y + &self.X;
let Y_minus_X = &self.Y - &self.X;
let PP = &Y_plus_X * &other.y_plus_x;
@ -473,10 +473,10 @@ impl<'a, 'b> Add<&'b AffineNielsPoint> for &'a EdwardsPoint {
}
//#[doc(hidden)]
impl<'a, 'b> Sub<&'b AffineNielsPoint> for &'a EdwardsPoint {
impl<'a> Sub<&'a AffineNielsPoint> for &EdwardsPoint {
type Output = CompletedPoint;
fn sub(self, other: &'b AffineNielsPoint) -> CompletedPoint {
fn sub(self, other: &'a AffineNielsPoint) -> CompletedPoint {
let Y_plus_X = &self.Y + &self.X;
let Y_minus_X = &self.Y - &self.X;
let PM = &Y_plus_X * &other.y_minus_x;
@ -497,7 +497,7 @@ impl<'a, 'b> Sub<&'b AffineNielsPoint> for &'a EdwardsPoint {
// Negation
// ------------------------------------------------------------------------
impl<'a> Neg for &'a ProjectiveNielsPoint {
impl Neg for &ProjectiveNielsPoint {
type Output = ProjectiveNielsPoint;
fn neg(self) -> ProjectiveNielsPoint {
@ -510,7 +510,7 @@ impl<'a> Neg for &'a ProjectiveNielsPoint {
}
}
impl<'a> Neg for &'a AffineNielsPoint {
impl Neg for &AffineNielsPoint {
type Output = AffineNielsPoint;
fn neg(self) -> AffineNielsPoint {

View file

@ -55,33 +55,33 @@ impl Zeroize for FieldElement51 {
}
}
impl<'b> AddAssign<&'b FieldElement51> for FieldElement51 {
fn add_assign(&mut self, _rhs: &'b FieldElement51) {
impl<'a> AddAssign<&'a FieldElement51> for FieldElement51 {
fn add_assign(&mut self, _rhs: &'a FieldElement51) {
for i in 0..5 {
self.0[i] += _rhs.0[i];
}
}
}
impl<'a, 'b> Add<&'b FieldElement51> for &'a FieldElement51 {
impl<'a> Add<&'a FieldElement51> for &FieldElement51 {
type Output = FieldElement51;
fn add(self, _rhs: &'b FieldElement51) -> FieldElement51 {
fn add(self, _rhs: &'a FieldElement51) -> FieldElement51 {
let mut output = *self;
output += _rhs;
output
}
}
impl<'b> SubAssign<&'b FieldElement51> for FieldElement51 {
fn sub_assign(&mut self, _rhs: &'b FieldElement51) {
impl<'a> SubAssign<&'a FieldElement51> for FieldElement51 {
fn sub_assign(&mut self, _rhs: &'a FieldElement51) {
let result = (self as &FieldElement51) - _rhs;
self.0 = result.0;
}
}
impl<'a, 'b> Sub<&'b FieldElement51> for &'a FieldElement51 {
impl<'a> Sub<&'a FieldElement51> for &FieldElement51 {
type Output = FieldElement51;
fn sub(self, _rhs: &'b FieldElement51) -> FieldElement51 {
fn sub(self, _rhs: &'a FieldElement51) -> FieldElement51 {
// To avoid underflow, first add a multiple of p.
// Choose 16*p = p << 4 to be larger than 54-bit _rhs.
//
@ -101,18 +101,18 @@ impl<'a, 'b> Sub<&'b FieldElement51> for &'a FieldElement51 {
}
}
impl<'b> MulAssign<&'b FieldElement51> for FieldElement51 {
fn mul_assign(&mut self, _rhs: &'b FieldElement51) {
impl<'a> MulAssign<&'a FieldElement51> for FieldElement51 {
fn mul_assign(&mut self, _rhs: &'a FieldElement51) {
let result = (self as &FieldElement51) * _rhs;
self.0 = result.0;
}
}
impl<'a, 'b> Mul<&'b FieldElement51> for &'a FieldElement51 {
impl<'a> Mul<&'a FieldElement51> for &FieldElement51 {
type Output = FieldElement51;
#[rustfmt::skip] // keep alignment of c* calculations
fn mul(self, _rhs: &'b FieldElement51) -> FieldElement51 {
fn mul(self, _rhs: &'a FieldElement51) -> FieldElement51 {
/// Helper function to multiply two 64-bit integers with 128
/// bits of output.
#[inline(always)]
@ -213,7 +213,7 @@ impl<'a, 'b> Mul<&'b FieldElement51> for &'a FieldElement51 {
}
}
impl<'a> Neg for &'a FieldElement51 {
impl Neg for &FieldElement51 {
type Output = FieldElement51;
fn neg(self) -> FieldElement51 {
let mut output = *self;

View file

@ -694,9 +694,9 @@ impl EdwardsPoint {
// Addition and Subtraction
// ------------------------------------------------------------------------
impl<'a, 'b> Add<&'b EdwardsPoint> for &'a EdwardsPoint {
impl<'a> Add<&'a EdwardsPoint> for &EdwardsPoint {
type Output = EdwardsPoint;
fn add(self, other: &'b EdwardsPoint) -> EdwardsPoint {
fn add(self, other: &'a EdwardsPoint) -> EdwardsPoint {
(self + &other.as_projective_niels()).as_extended()
}
}
@ -707,17 +707,17 @@ define_add_variants!(
Output = EdwardsPoint
);
impl<'b> AddAssign<&'b EdwardsPoint> for EdwardsPoint {
fn add_assign(&mut self, _rhs: &'b EdwardsPoint) {
impl<'a> AddAssign<&'a EdwardsPoint> for EdwardsPoint {
fn add_assign(&mut self, _rhs: &'a EdwardsPoint) {
*self = (self as &EdwardsPoint) + _rhs;
}
}
define_add_assign_variants!(LHS = EdwardsPoint, RHS = EdwardsPoint);
impl<'a, 'b> Sub<&'b EdwardsPoint> for &'a EdwardsPoint {
impl<'a> Sub<&'a EdwardsPoint> for &EdwardsPoint {
type Output = EdwardsPoint;
fn sub(self, other: &'b EdwardsPoint) -> EdwardsPoint {
fn sub(self, other: &'a EdwardsPoint) -> EdwardsPoint {
(self - &other.as_projective_niels()).as_extended()
}
}
@ -728,8 +728,8 @@ define_sub_variants!(
Output = EdwardsPoint
);
impl<'b> SubAssign<&'b EdwardsPoint> for EdwardsPoint {
fn sub_assign(&mut self, _rhs: &'b EdwardsPoint) {
impl<'a> SubAssign<&'a EdwardsPoint> for EdwardsPoint {
fn sub_assign(&mut self, _rhs: &'a EdwardsPoint) {
*self = (self as &EdwardsPoint) - _rhs;
}
}
@ -752,7 +752,7 @@ where
// Negation
// ------------------------------------------------------------------------
impl<'a> Neg for &'a EdwardsPoint {
impl Neg for &EdwardsPoint {
type Output = EdwardsPoint;
fn neg(self) -> EdwardsPoint {
@ -777,8 +777,8 @@ impl Neg for EdwardsPoint {
// Scalar multiplication
// ------------------------------------------------------------------------
impl<'b> MulAssign<&'b Scalar> for EdwardsPoint {
fn mul_assign(&mut self, scalar: &'b Scalar) {
impl<'a> MulAssign<&'a Scalar> for EdwardsPoint {
fn mul_assign(&mut self, scalar: &'a Scalar) {
let result = (self as &EdwardsPoint) * scalar;
*self = result;
}
@ -789,25 +789,25 @@ define_mul_assign_variants!(LHS = EdwardsPoint, RHS = Scalar);
define_mul_variants!(LHS = EdwardsPoint, RHS = Scalar, Output = EdwardsPoint);
define_mul_variants!(LHS = Scalar, RHS = EdwardsPoint, Output = EdwardsPoint);
impl<'a, 'b> Mul<&'b Scalar> for &'a EdwardsPoint {
impl<'a> Mul<&'a Scalar> for &EdwardsPoint {
type Output = EdwardsPoint;
/// Scalar multiplication: compute `scalar * self`.
///
/// For scalar multiplication of a basepoint,
/// `EdwardsBasepointTable` is approximately 4x faster.
fn mul(self, scalar: &'b Scalar) -> EdwardsPoint {
fn mul(self, scalar: &'a Scalar) -> EdwardsPoint {
crate::backend::variable_base_mul(self, scalar)
}
}
impl<'a, 'b> Mul<&'b EdwardsPoint> for &'a Scalar {
impl<'a> Mul<&'a EdwardsPoint> for &Scalar {
type Output = EdwardsPoint;
/// Scalar multiplication: compute `scalar * self`.
///
/// For scalar multiplication of a basepoint,
/// `EdwardsBasepointTable` is approximately 4x faster.
fn mul(self, point: &'b EdwardsPoint) -> EdwardsPoint {
fn mul(self, point: &'a EdwardsPoint) -> EdwardsPoint {
point * self
}
}

View file

@ -543,7 +543,7 @@ mod test {
let mut csprng = rand_core::OsRng;
for _ in 0..100 {
let p_edwards = rand_prime_order_point(&mut csprng);
let p_edwards = rand_prime_order_point(csprng);
let p_montgomery: MontgomeryPoint = p_edwards.to_montgomery();
let s: Scalar = Scalar::random(&mut csprng);
@ -562,7 +562,7 @@ mod test {
for _ in 0..100 {
// Make a random prime-order point P
let p_edwards = rand_prime_order_point(&mut csprng);
let p_edwards = rand_prime_order_point(csprng);
let p_montgomery: MontgomeryPoint = p_edwards.to_montgomery();
// Make a random integer b

View file

@ -848,10 +848,10 @@ impl Eq for RistrettoPoint {}
// Arithmetic
// ------------------------------------------------------------------------
impl<'a, 'b> Add<&'b RistrettoPoint> for &'a RistrettoPoint {
impl<'a> Add<&'a RistrettoPoint> for &RistrettoPoint {
type Output = RistrettoPoint;
fn add(self, other: &'b RistrettoPoint) -> RistrettoPoint {
fn add(self, other: &'a RistrettoPoint) -> RistrettoPoint {
RistrettoPoint(self.0 + other.0)
}
}
@ -862,7 +862,7 @@ define_add_variants!(
Output = RistrettoPoint
);
impl<'b> AddAssign<&'b RistrettoPoint> for RistrettoPoint {
impl AddAssign<&RistrettoPoint> for RistrettoPoint {
fn add_assign(&mut self, _rhs: &RistrettoPoint) {
*self = (self as &RistrettoPoint) + _rhs;
}
@ -870,10 +870,10 @@ impl<'b> AddAssign<&'b RistrettoPoint> for RistrettoPoint {
define_add_assign_variants!(LHS = RistrettoPoint, RHS = RistrettoPoint);
impl<'a, 'b> Sub<&'b RistrettoPoint> for &'a RistrettoPoint {
impl<'a> Sub<&'a RistrettoPoint> for &RistrettoPoint {
type Output = RistrettoPoint;
fn sub(self, other: &'b RistrettoPoint) -> RistrettoPoint {
fn sub(self, other: &'a RistrettoPoint) -> RistrettoPoint {
RistrettoPoint(self.0 - other.0)
}
}
@ -884,7 +884,7 @@ define_sub_variants!(
Output = RistrettoPoint
);
impl<'b> SubAssign<&'b RistrettoPoint> for RistrettoPoint {
impl SubAssign<&RistrettoPoint> for RistrettoPoint {
fn sub_assign(&mut self, _rhs: &RistrettoPoint) {
*self = (self as &RistrettoPoint) - _rhs;
}
@ -904,7 +904,7 @@ where
}
}
impl<'a> Neg for &'a RistrettoPoint {
impl Neg for &RistrettoPoint {
type Output = RistrettoPoint;
fn neg(self) -> RistrettoPoint {
@ -920,26 +920,26 @@ impl Neg for RistrettoPoint {
}
}
impl<'b> MulAssign<&'b Scalar> for RistrettoPoint {
fn mul_assign(&mut self, scalar: &'b Scalar) {
impl<'a> MulAssign<&'a Scalar> for RistrettoPoint {
fn mul_assign(&mut self, scalar: &'a Scalar) {
let result = (self as &RistrettoPoint) * scalar;
*self = result;
}
}
impl<'a, 'b> Mul<&'b Scalar> for &'a RistrettoPoint {
impl<'a> Mul<&'a Scalar> for &RistrettoPoint {
type Output = RistrettoPoint;
/// Scalar multiplication: compute `scalar * self`.
fn mul(self, scalar: &'b Scalar) -> RistrettoPoint {
fn mul(self, scalar: &'a Scalar) -> RistrettoPoint {
RistrettoPoint(self.0 * scalar)
}
}
impl<'a, 'b> Mul<&'b RistrettoPoint> for &'a Scalar {
impl<'a> Mul<&'a RistrettoPoint> for &Scalar {
type Output = RistrettoPoint;
/// Scalar multiplication: compute `self * scalar`.
fn mul(self, point: &'b RistrettoPoint) -> RistrettoPoint {
fn mul(self, point: &'a RistrettoPoint) -> RistrettoPoint {
RistrettoPoint(self * point.0)
}
}
@ -1093,7 +1093,7 @@ impl RistrettoPoint {
pub struct RistrettoBasepointTable(pub(crate) EdwardsBasepointTable);
#[cfg(feature = "precomputed-tables")]
impl<'a, 'b> Mul<&'b Scalar> for &'a RistrettoBasepointTable {
impl<'b> Mul<&'b Scalar> for &RistrettoBasepointTable {
type Output = RistrettoPoint;
fn mul(self, scalar: &'b Scalar) -> RistrettoPoint {
@ -1102,7 +1102,7 @@ impl<'a, 'b> Mul<&'b Scalar> for &'a RistrettoBasepointTable {
}
#[cfg(feature = "precomputed-tables")]
impl<'a, 'b> Mul<&'a RistrettoBasepointTable> for &'b Scalar {
impl<'a> Mul<&'a RistrettoBasepointTable> for &Scalar {
type Output = RistrettoPoint;
fn mul(self, basepoint_table: &'a RistrettoBasepointTable) -> RistrettoPoint {

View file

@ -312,35 +312,35 @@ impl Index<usize> for Scalar {
}
}
impl<'b> MulAssign<&'b Scalar> for Scalar {
fn mul_assign(&mut self, _rhs: &'b Scalar) {
impl<'a> MulAssign<&'a Scalar> for Scalar {
fn mul_assign(&mut self, _rhs: &'a Scalar) {
*self = UnpackedScalar::mul(&self.unpack(), &_rhs.unpack()).pack();
}
}
define_mul_assign_variants!(LHS = Scalar, RHS = Scalar);
impl<'a, 'b> Mul<&'b Scalar> for &'a Scalar {
impl<'a> Mul<&'a Scalar> for &Scalar {
type Output = Scalar;
fn mul(self, _rhs: &'b Scalar) -> Scalar {
fn mul(self, _rhs: &'a Scalar) -> Scalar {
UnpackedScalar::mul(&self.unpack(), &_rhs.unpack()).pack()
}
}
define_mul_variants!(LHS = Scalar, RHS = Scalar, Output = Scalar);
impl<'b> AddAssign<&'b Scalar> for Scalar {
fn add_assign(&mut self, _rhs: &'b Scalar) {
impl<'a> AddAssign<&'a Scalar> for Scalar {
fn add_assign(&mut self, _rhs: &'a Scalar) {
*self = *self + _rhs;
}
}
define_add_assign_variants!(LHS = Scalar, RHS = Scalar);
impl<'a, 'b> Add<&'b Scalar> for &'a Scalar {
impl<'a> Add<&'a Scalar> for &Scalar {
type Output = Scalar;
#[allow(non_snake_case)]
fn add(self, _rhs: &'b Scalar) -> Scalar {
fn add(self, _rhs: &'a Scalar) -> Scalar {
// The UnpackedScalar::add function produces reduced outputs if the inputs are reduced. By
// Scalar invariant #1, this is always the case.
UnpackedScalar::add(&self.unpack(), &_rhs.unpack()).pack()
@ -349,18 +349,18 @@ impl<'a, 'b> Add<&'b Scalar> for &'a Scalar {
define_add_variants!(LHS = Scalar, RHS = Scalar, Output = Scalar);
impl<'b> SubAssign<&'b Scalar> for Scalar {
fn sub_assign(&mut self, _rhs: &'b Scalar) {
impl<'a> SubAssign<&'a Scalar> for Scalar {
fn sub_assign(&mut self, _rhs: &'a Scalar) {
*self = *self - _rhs;
}
}
define_sub_assign_variants!(LHS = Scalar, RHS = Scalar);
impl<'a, 'b> Sub<&'b Scalar> for &'a Scalar {
impl<'a> Sub<&'a Scalar> for &Scalar {
type Output = Scalar;
#[allow(non_snake_case)]
fn sub(self, rhs: &'b Scalar) -> Scalar {
fn sub(self, rhs: &'a Scalar) -> Scalar {
// The UnpackedScalar::sub function produces reduced outputs if the inputs are reduced. By
// Scalar invariant #1, this is always the case.
UnpackedScalar::sub(&self.unpack(), &rhs.unpack()).pack()
@ -369,7 +369,7 @@ impl<'a, 'b> Sub<&'b Scalar> for &'a Scalar {
define_sub_variants!(LHS = Scalar, RHS = Scalar, Output = Scalar);
impl<'a> Neg for &'a Scalar {
impl Neg for &Scalar {
type Output = Scalar;
#[allow(non_snake_case)]
fn neg(self) -> Scalar {

View file

@ -317,8 +317,8 @@ mod test {
#[test]
fn sign_byupdate() {
// Generate the keypair
let mut rng = OsRng;
let esk = ExpandedSecretKey::random(&mut rng);
let rng = OsRng;
let esk = ExpandedSecretKey::random(rng);
let vk = VerifyingKey::from(&esk);
let msg = b"realistic";