Skip to content

Commit

Permalink
Fix more clippy warnings from new rust update
Browse files Browse the repository at this point in the history
  • Loading branch information
inetic committed Dec 10, 2024
1 parent ec44b2a commit 12e9ec0
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 29 deletions.
4 changes: 2 additions & 2 deletions deadlock/src/async_mutex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ pub struct MutexGuard<'a, T> {
_tracker: ExpectShortLifetime,
}

impl<'a, T> Deref for MutexGuard<'a, T> {
impl<T> Deref for MutexGuard<'_, T> {
type Target = T;

fn deref(&self) -> &Self::Target {
self.inner.deref()
}
}

impl<'a, T> DerefMut for MutexGuard<'a, T> {
impl<T> DerefMut for MutexGuard<'_, T> {
fn deref_mut(&mut self) -> &mut Self::Target {
self.inner.deref_mut()
}
Expand Down
2 changes: 1 addition & 1 deletion lib/src/crypto/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ pub trait Hashable {
}
}

impl<'a, T> Hashable for &'a T
impl<T> Hashable for &T
where
T: Hashable + ?Sized,
{
Expand Down
2 changes: 1 addition & 1 deletion lib/src/future.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ pin_project! {
}
}

impl<'a, S, D> Future for TryCollectInto<'a, S, D>
impl<S, D> Future for TryCollectInto<'_, S, D>
where
S: TryStream,
D: Extend<S::Ok>,
Expand Down
4 changes: 2 additions & 2 deletions lib/src/network/peer_exchange.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ impl PexSender {
/// Collects contacts of other peers to be sent to this peer.
pub(crate) struct PexCollector<'a>(&'a PexSender);

impl<'a> PexCollector<'a> {
impl PexCollector<'_> {
fn collect(&self) -> Result<HashSet<PeerAddr>, CollectError> {
let state = self.0.state.borrow();

Expand Down Expand Up @@ -324,7 +324,7 @@ impl<'a> PexCollector<'a> {
}
}

impl<'a> Drop for PexCollector<'a> {
impl Drop for PexCollector<'_> {
fn drop(&mut self) {
self.0.state.send_modify(|state| {
if let Some(repo) = state.repos.get_mut(self.0.repo_id) {
Expand Down
8 changes: 4 additions & 4 deletions lib/src/network/runtime_id.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
//! These structures are used to generate ephemeral id that uniquely identifies a replica. Changes
//! every time the replica is restarted. The cryptography involved is to ensure one replica can't
//! claim to be another one.
use crate::crypto::{
sign::{Keypair, PublicKey, Signature},
Digest, Hashable,
Expand All @@ -7,10 +11,6 @@ use serde::{Deserialize, Serialize};
use std::io;
use tokio::io::{AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt};

/// These structures are used to generate ephemeral id that uniquely identifies a replica. Changes
/// every time the replica is restarted. The cryptography involved is to ensure one replica can't
/// claim to be another one.
pub struct SecretRuntimeId {
keypair: Keypair,
}
Expand Down
20 changes: 10 additions & 10 deletions lib/src/network/seen_peers.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
//! When a peer is found using some discovery mechanisms (local discovery, DHT, PEX, ...), the
//! networking code will try to connect to it. However, if connecting to the peer fails we would
//! like to keep trying to connect to it again. On one hand we don't want to keep trying to connect
//! to the peer indefinitely, but on the other hand we also don't want to wait until the next time
//! the discovery mechanism finds the peer (which may be more than 10 minutes).
//!
//! This code solves the problem by giving the networking code a `SeenPeer` structure that
//! dereferences to `Some(PeerAddr)` for as long as the discovery mechanism "thinks" the peer
//! is still available, and to `None` once the mechanism hasn't seen the peer for a while.
use super::PeerAddr;
use crate::collections::{HashMap, HashSet};
use deadlock::BlockingRwLock;
use std::{fmt, sync::Arc};
use tokio::sync::watch;

/// When a peer is found using some discovery mechanisms (local discovery, DHT, PEX, ...), the
/// networking code will try to connect to it. However, if connecting to the peer fails we would
/// like to keep trying to connect to it again. On one hand we don't want to keep trying to connect
/// to the peer indefinitely, but on the other hand we also don't want to wait until the next time
/// the discovery mechanism finds the peer (which may be more than 10 minutes).
///
/// This code solves the problem by giving the networking code a `SeenPeer` structure that
/// dereferences to `Some(PeerAddr)` for as long as the discovery mechanism "thinks" the peer
/// is still available, and to `None` once the mechanism hasn't seen the peer for a while.
// When a peer has not been seen after this many rounds, it'll be removed.
const REMOVE_AFTER_ROUND_COUNT: u64 = 2;

Expand Down
2 changes: 1 addition & 1 deletion lib/src/version_vector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ impl FromIterator<(PublicKey, u64)> for VersionVector {
}
}

impl<'a> Add for &'a VersionVector {
impl Add for &VersionVector {
type Output = VersionVector;

fn add(self, other: Self) -> Self::Output {
Expand Down
1 change: 0 additions & 1 deletion lib/tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,6 @@ pub(crate) async fn wait(rx: &mut broadcast::Receiver<Event>) -> Option<Payload>

/// Wait until the file at `path` has the expected content. Panics if timeout elapses before the
/// file content matches.
pub(crate) async fn expect_file_content(repo: &Repository, path: &str, expected_content: &[u8]) {
expect_file_version_content(repo, path, None, expected_content).await
}
Expand Down
10 changes: 5 additions & 5 deletions state_monitor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -436,21 +436,21 @@ pub struct MutexGuardWrap<'a, T> {
guard: BlockingMutexGuard<'a, T>,
}

impl<'a, T> core::ops::Deref for MutexGuardWrap<'a, T> {
impl<T> core::ops::Deref for MutexGuardWrap<'_, T> {
type Target = T;

fn deref(&self) -> &T {
&self.guard
}
}

impl<'a, T> core::ops::DerefMut for MutexGuardWrap<'a, T> {
impl<T> core::ops::DerefMut for MutexGuardWrap<'_, T> {
fn deref_mut(&mut self) -> &mut T {
&mut self.guard
}
}

impl<'a, T> Drop for MutexGuardWrap<'a, T> {
impl<T> Drop for MutexGuardWrap<'_, T> {
fn drop(&mut self) {
self.monitor.shared.changed();
}
Expand Down Expand Up @@ -531,7 +531,7 @@ impl Serialize for StateMonitor {
struct ValuesSerializer<'a>(&'a IndexMap<String, MonitoredValueHandle>);
struct ChildrenSerializer<'a>(&'a IndexMap<MonitorId, ChildEntry>);

impl<'a> Serialize for ValuesSerializer<'a> {
impl Serialize for ValuesSerializer<'_> {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
Expand All @@ -545,7 +545,7 @@ impl<'a> Serialize for ValuesSerializer<'a> {
}
}

impl<'a> Serialize for ChildrenSerializer<'a> {
impl Serialize for ChildrenSerializer<'_> {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
Expand Down
4 changes: 2 additions & 2 deletions vfs/src/fuse/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ pub enum MaybeOwnedMut<'a, T> {
Borrowed(&'a mut T),
}

impl<'a, T> Deref for MaybeOwnedMut<'a, T> {
impl<T> Deref for MaybeOwnedMut<'_, T> {
type Target = T;

fn deref(&self) -> &Self::Target {
Expand All @@ -76,7 +76,7 @@ impl<'a, T> Deref for MaybeOwnedMut<'a, T> {
}
}

impl<'a, T> DerefMut for MaybeOwnedMut<'a, T> {
impl<T> DerefMut for MaybeOwnedMut<'_, T> {
fn deref_mut(&mut self) -> &mut Self::Target {
match self {
Self::Owned(v) => v,
Expand Down

0 comments on commit 12e9ec0

Please sign in to comment.