Skip to content

Commit

Permalink
Fixing clippy issues present in upgraded rust version (#155)
Browse files Browse the repository at this point in the history
Fixes new clippy issues noted by rust nightly 01-27-25.
  • Loading branch information
hoytak authored Jan 29, 2025
1 parent 0f61841 commit 8735ca3
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 17 deletions.
2 changes: 1 addition & 1 deletion cas_types/src/key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ pub mod hex {
// Visitor for deserialization
struct HexVisitor;

impl<'de> Visitor<'de> for HexVisitor {
impl Visitor<'_> for HexVisitor {
type Value = MerkleHash;

fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
Expand Down
6 changes: 3 additions & 3 deletions mdb_shard/src/shard_file_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ lazy_static! {
}

// The structure used as the target for the dedup lookup
#[repr(packed)]
#[repr(Rust, packed)]
struct ChunkCacheElement {
cas_start_index: u32, // the index of the first chunk
cas_chunk_offset: u16,
Expand Down Expand Up @@ -417,9 +417,9 @@ impl ShardFileManager {
Ok(())
}

async fn flush_internal<'a>(
async fn flush_internal(
&self,
mem_shard: &mut tokio::sync::RwLockWriteGuard<'a, MDBShardFlushGuard>,
mem_shard: &mut tokio::sync::RwLockWriteGuard<'_, MDBShardFlushGuard>,
) -> Result<Option<PathBuf>> {
Ok(if let Some(path) = mem_shard.flush()? {
self.load_and_cleanup_shards_by_path(&[&path]).await?;
Expand Down
5 changes: 1 addition & 4 deletions mdb_shard/src/shard_in_memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,7 @@ impl MDBInMemoryShard {
return None;
}

let (chunk_ref, chunk_index_start) = match self.chunk_hash_lookup.get(&query_hashes[0]) {
Some(s) => s,
None => return None,
};
let (chunk_ref, chunk_index_start) = self.chunk_hash_lookup.get(&query_hashes[0])?;

let chunk_index_start = *chunk_index_start as usize;

Expand Down
4 changes: 2 additions & 2 deletions merkledb/src/async_chunk_iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,8 @@ where

struct HasherPointerBox<'a>(*mut gearhash::Hasher<'a>);

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

/// low Variance Chunk Generator given an input stream. Do not use directly.
/// Use `async_chunk_target_default` or `async_low_variance_chunk_target`.
Expand Down
4 changes: 2 additions & 2 deletions merkledb/src/chunk_iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ fn fill_buf(reader: &mut impl Read, buf: &mut [u8]) -> io::Result<usize> {
reader.read(buf)
}

impl<'a, T: Read> Chunker<'a, T> {
impl<T: Read> Chunker<'_, T> {
fn gen(&mut self) -> Vec<Chunk> {
let mut ret: Vec<Chunk> = Vec::with_capacity(1024);
let mut chunkbuf: Vec<u8> = Vec::with_capacity(self.maximum_chunk);
Expand Down Expand Up @@ -136,7 +136,7 @@ pub struct LowVarianceChunker<'a, T: Read> {
mask: u64,
}

impl<'a, T: Read> LowVarianceChunker<'a, T> {
impl<T: Read> LowVarianceChunker<'_, T> {
fn gen(&mut self) -> Vec<Chunk> {
let mut ret: Vec<Chunk> = Vec::with_capacity(1024);
let mut chunkbuf: Vec<u8> = Vec::with_capacity(self.maximum_chunk);
Expand Down
5 changes: 2 additions & 3 deletions merkledb/src/merkledbbase.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
use super::error::*;
use super::merklenode::*;

/**
Basic Concepts
==============
Expand Down Expand Up @@ -70,6 +67,8 @@ Root: This are nodes in the MerkleDAG with no parent.
File Root: This are nodes in the MerkleDAG which correspond to actual user files.
*/
use super::error::*;
use super::merklenode::*;

/**
* This defines the basic minimal database interface for a MerkleDB.
Expand Down
4 changes: 2 additions & 2 deletions utils/src/async_read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ pub struct CopyReader<'r, 'w, R, W> {
writer: &'w mut W,
}

impl<'r, 'w, R: AsyncRead + Unpin, W: Write> AsyncRead for CopyReader<'r, 'w, R, W> {
impl<R: AsyncRead + Unpin, W: Write> AsyncRead for CopyReader<'_, '_, R, W> {
fn poll_read(mut self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &mut [u8]) -> Poll<std::io::Result<usize>> {
let res = ready!(self.src.as_mut().poll_read(cx, buf))?;
self.writer.write_all(&buf[..res])?;
Poll::Ready(Ok(res))
}
}

impl<'r, 'w, R: AsyncRead + Unpin, W: Write> Unpin for CopyReader<'r, 'w, R, W> {}
impl<R: AsyncRead + Unpin, W: Write> Unpin for CopyReader<'_, '_, R, W> {}

impl<'r, 'w, R: AsyncRead + Unpin, W: Write> CopyReader<'r, 'w, R, W> {
pub fn new(src: &'r mut R, writer: &'w mut W) -> Self {
Expand Down

0 comments on commit 8735ca3

Please sign in to comment.