Skip to content

Commit

Permalink
Clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
kornelski committed Nov 28, 2024
1 parent aa16061 commit 8d314fe
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 30 deletions.
1 change: 1 addition & 0 deletions boring/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ readme = "README.md"
keywords = ["crypto", "tls", "ssl", "dtls"]
categories = ["cryptography", "api-bindings"]
edition = { workspace = true }
rust-version = "1.70"

[package.metadata.docs.rs]
features = ["rpk", "pq-experimental", "underscore-wildcards"]
Expand Down
4 changes: 2 additions & 2 deletions boring/src/asn1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ impl PartialEq<Asn1Time> for Asn1TimeRef {
}
}

impl<'a> PartialEq<Asn1Time> for &'a Asn1TimeRef {
impl PartialEq<Asn1Time> for &Asn1TimeRef {
fn eq(&self, other: &Asn1Time) -> bool {
self.diff(other)
.map(|t| t.days == 0 && t.secs == 0)
Expand All @@ -253,7 +253,7 @@ impl PartialOrd<Asn1Time> for Asn1TimeRef {
}
}

impl<'a> PartialOrd<Asn1Time> for &'a Asn1TimeRef {
impl PartialOrd<Asn1Time> for &Asn1TimeRef {
fn partial_cmp(&self, other: &Asn1Time) -> Option<Ordering> {
self.compare(other).ok()
}
Expand Down
2 changes: 1 addition & 1 deletion boring/src/bio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::error::ErrorStack;

pub struct MemBioSlice<'a>(*mut ffi::BIO, PhantomData<&'a [u8]>);

impl<'a> Drop for MemBioSlice<'a> {
impl Drop for MemBioSlice<'_> {
fn drop(&mut self) {
unsafe {
ffi::BIO_free_all(self.0);
Expand Down
22 changes: 11 additions & 11 deletions boring/src/bn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1012,7 +1012,7 @@ macro_rules! delegate {
};
}

impl<'a, 'b> Add<&'b BigNumRef> for &'a BigNumRef {
impl Add<&BigNumRef> for &BigNumRef {
type Output = BigNum;

fn add(self, oth: &BigNumRef) -> BigNum {
Expand All @@ -1024,7 +1024,7 @@ impl<'a, 'b> Add<&'b BigNumRef> for &'a BigNumRef {

delegate!(Add, add);

impl<'a, 'b> Sub<&'b BigNumRef> for &'a BigNumRef {
impl Sub<&BigNumRef> for &BigNumRef {
type Output = BigNum;

fn sub(self, oth: &BigNumRef) -> BigNum {
Expand All @@ -1036,7 +1036,7 @@ impl<'a, 'b> Sub<&'b BigNumRef> for &'a BigNumRef {

delegate!(Sub, sub);

impl<'a, 'b> Mul<&'b BigNumRef> for &'a BigNumRef {
impl Mul<&BigNumRef> for &BigNumRef {
type Output = BigNum;

fn mul(self, oth: &BigNumRef) -> BigNum {
Expand All @@ -1049,7 +1049,7 @@ impl<'a, 'b> Mul<&'b BigNumRef> for &'a BigNumRef {

delegate!(Mul, mul);

impl<'a, 'b> Div<&'b BigNumRef> for &'a BigNumRef {
impl<'b> Div<&'b BigNumRef> for &BigNumRef {
type Output = BigNum;

fn div(self, oth: &'b BigNumRef) -> BigNum {
Expand All @@ -1062,7 +1062,7 @@ impl<'a, 'b> Div<&'b BigNumRef> for &'a BigNumRef {

delegate!(Div, div);

impl<'a, 'b> Rem<&'b BigNumRef> for &'a BigNumRef {
impl<'b> Rem<&'b BigNumRef> for &BigNumRef {
type Output = BigNum;

fn rem(self, oth: &'b BigNumRef) -> BigNum {
Expand All @@ -1075,7 +1075,7 @@ impl<'a, 'b> Rem<&'b BigNumRef> for &'a BigNumRef {

delegate!(Rem, rem);

impl<'a> Shl<i32> for &'a BigNumRef {
impl Shl<i32> for &BigNumRef {
type Output = BigNum;

fn shl(self, n: i32) -> BigNum {
Expand All @@ -1085,15 +1085,15 @@ impl<'a> Shl<i32> for &'a BigNumRef {
}
}

impl<'a> Shl<i32> for &'a BigNum {
impl Shl<i32> for &BigNum {
type Output = BigNum;

fn shl(self, n: i32) -> BigNum {
self.deref().shl(n)
}
}

impl<'a> Shr<i32> for &'a BigNumRef {
impl Shr<i32> for &BigNumRef {
type Output = BigNum;

fn shr(self, n: i32) -> BigNum {
Expand All @@ -1103,23 +1103,23 @@ impl<'a> Shr<i32> for &'a BigNumRef {
}
}

impl<'a> Shr<i32> for &'a BigNum {
impl Shr<i32> for &BigNum {
type Output = BigNum;

fn shr(self, n: i32) -> BigNum {
self.deref().shr(n)
}
}

impl<'a> Neg for &'a BigNumRef {
impl Neg for &BigNumRef {
type Output = BigNum;

fn neg(self) -> BigNum {
self.to_owned().unwrap().neg()
}
}

impl<'a> Neg for &'a BigNum {
impl Neg for &BigNum {
type Output = BigNum;

fn neg(self) -> BigNum {
Expand Down
6 changes: 3 additions & 3 deletions boring/src/derive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ use crate::{cvt, cvt_p};
/// A type used to derive a shared secret between two keys.
pub struct Deriver<'a>(*mut ffi::EVP_PKEY_CTX, PhantomData<&'a ()>);

unsafe impl<'a> Sync for Deriver<'a> {}
unsafe impl<'a> Send for Deriver<'a> {}
unsafe impl Sync for Deriver<'_> {}
unsafe impl Send for Deriver<'_> {}

impl<'a> Drop for Deriver<'a> {
impl Drop for Deriver<'_> {
fn drop(&mut self) {
unsafe {
ffi::EVP_PKEY_CTX_free(self.0);
Expand Down
16 changes: 8 additions & 8 deletions boring/src/sign.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ pub struct Signer<'a> {
_p: PhantomData<&'a ()>,
}

unsafe impl<'a> Sync for Signer<'a> {}
unsafe impl<'a> Send for Signer<'a> {}
unsafe impl Sync for Signer<'_> {}
unsafe impl Send for Signer<'_> {}

impl<'a> Drop for Signer<'a> {
impl Drop for Signer<'_> {
fn drop(&mut self) {
// pkey_ctx is owned by the md_ctx, so no need to explicitly free it.
unsafe {
Expand Down Expand Up @@ -337,7 +337,7 @@ impl<'a> Signer<'a> {
}
}

impl<'a> Write for Signer<'a> {
impl Write for Signer<'_> {
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
self.update(buf)?;
Ok(buf.len())
Expand All @@ -354,10 +354,10 @@ pub struct Verifier<'a> {
pkey_pd: PhantomData<&'a ()>,
}

unsafe impl<'a> Sync for Verifier<'a> {}
unsafe impl<'a> Send for Verifier<'a> {}
unsafe impl Sync for Verifier<'_> {}
unsafe impl Send for Verifier<'_> {}

impl<'a> Drop for Verifier<'a> {
impl Drop for Verifier<'_> {
fn drop(&mut self) {
// pkey_ctx is owned by the md_ctx, so no need to explicitly free it.
unsafe {
Expand Down Expand Up @@ -560,7 +560,7 @@ impl<'a> Verifier<'a> {
}
}

impl<'a> Write for Verifier<'a> {
impl Write for Verifier<'_> {
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
self.update(buf)?;
Ok(buf.len())
Expand Down
2 changes: 1 addition & 1 deletion boring/src/ssl/bio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ struct BIO_METHOD(*mut ffi::BIO_METHOD);
impl BIO_METHOD {
fn new<S: Read + Write>() -> BIO_METHOD {
unsafe {
let ptr = ffi::BIO_meth_new(ffi::BIO_TYPE_NONE, b"rust\0".as_ptr() as *const _);
let ptr = ffi::BIO_meth_new(ffi::BIO_TYPE_NONE, b"rust\0".as_ptr().cast());
assert!(!ptr.is_null());
let ret = BIO_METHOD(ptr);
assert!(ffi::BIO_meth_set_write(ptr, Some(bwrite::<S>)) != 0);
Expand Down
4 changes: 2 additions & 2 deletions boring/src/stack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ impl<'a, T: Stackable> DoubleEndedIterator for Iter<'a, T> {
}
}

impl<'a, T: Stackable> ExactSizeIterator for Iter<'a, T> {}
impl<T: Stackable> ExactSizeIterator for Iter<'_, T> {}

/// A mutable iterator over the stack's contents.
pub struct IterMut<'a, T: Stackable + 'a> {
Expand Down Expand Up @@ -372,4 +372,4 @@ impl<'a, T: Stackable> DoubleEndedIterator for IterMut<'a, T> {
}
}

impl<'a, T: Stackable> ExactSizeIterator for IterMut<'a, T> {}
impl<T: Stackable> ExactSizeIterator for IterMut<'_, T> {}
4 changes: 2 additions & 2 deletions boring/src/x509/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ impl X509StoreContextRef {
{
struct Cleanup<'a>(&'a mut X509StoreContextRef);

impl<'a> Drop for Cleanup<'a> {
impl Drop for Cleanup<'_> {
fn drop(&mut self) {
unsafe {
ffi::X509_STORE_CTX_cleanup(self.0.as_ptr());
Expand Down Expand Up @@ -722,7 +722,7 @@ impl Stackable for X509 {
/// A context object required to construct certain `X509` extension values.
pub struct X509v3Context<'a>(ffi::X509V3_CTX, PhantomData<(&'a X509Ref, &'a ConfRef)>);

impl<'a> X509v3Context<'a> {
impl X509v3Context<'_> {
pub fn as_ptr(&self) -> *mut ffi::X509V3_CTX {
&self.0 as *const _ as *mut _
}
Expand Down

0 comments on commit 8d314fe

Please sign in to comment.