From 89668d96899cd7a619b4b16d8f767e522ad46c1b Mon Sep 17 00:00:00 2001 From: C J Silverio Date: Mon, 23 Jan 2023 17:09:40 -0800 Subject: [PATCH] Fix CI with some linting - Removed extraneous commented-out dep from testing. - Updated Rust edition to 2021, as CI demanded. - Ran `cargo clippy --fix` to remove all the new lints. --- Cargo.toml | 2 +- benches/benchmarks.rs | 4 ++-- src/content/read.rs | 2 +- src/content/write.rs | 1 - src/get.rs | 12 ++++++------ src/index.rs | 4 ++-- src/rm.rs | 2 +- 7 files changed, 13 insertions(+), 14 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 6224c99..42dd6e7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ name = "cacache" version = "10.0.2-alpha.0" authors = ["Kat Marchán "] -edition = "2018" +edition = "2021" description = "Content-addressable, key-value, high-performance, on-disk cache." license = "Apache-2.0" repository = "https://github.com/zkat/cacache-rs" diff --git a/benches/benchmarks.rs b/benches/benchmarks.rs index 6f79ed0..99c974c 100644 --- a/benches/benchmarks.rs +++ b/benches/benchmarks.rs @@ -26,7 +26,7 @@ fn baseline_read_many_sync(c: &mut Criterion) { .collect(); let data = b"hello world"; for path in paths.iter() { - let mut fd = File::create(&path).unwrap(); + let mut fd = File::create(path).unwrap(); fd.write_all(data).unwrap(); drop(fd); } @@ -59,7 +59,7 @@ fn baseline_read_many_async(c: &mut Criterion) { .collect(); let data = b"hello world"; for path in paths.iter() { - let mut fd = File::create(&path).unwrap(); + let mut fd = File::create(path).unwrap(); fd.write_all(data).unwrap(); drop(fd); } diff --git a/src/content/read.rs b/src/content/read.rs index ade2c97..816d035 100644 --- a/src/content/read.rs +++ b/src/content/read.rs @@ -70,7 +70,7 @@ pub async fn open_async(cache: &Path, sri: Integrity) -> Result { pub fn read(cache: &Path, sri: &Integrity) -> Result> { let cpath = path::content_path(cache, sri); - let ret = fs::read(&cpath).to_internal()?; + let ret = fs::read(cpath).to_internal()?; sri.check(&ret)?; Ok(ret) } diff --git a/src/content/write.rs b/src/content/write.rs index 4471c37..f446f95 100644 --- a/src/content/write.rs +++ b/src/content/write.rs @@ -10,7 +10,6 @@ use async_std::task::{self, Context, JoinHandle, Poll}; use futures::io::AsyncWrite; use futures::prelude::*; use memmap2::MmapMut; -// use memmap::MmapMut; use ssri::{Algorithm, Integrity, IntegrityOpts}; use tempfile::NamedTempFile; diff --git a/src/get.rs b/src/get.rs index 573c081..55432d1 100644 --- a/src/get.rs +++ b/src/get.rs @@ -169,7 +169,7 @@ pub async fn read_hash

(cache: P, sri: &Integrity) -> Result> where P: AsRef, { - Ok(read::read_async(cache.as_ref(), sri).await?) + read::read_async(cache.as_ref(), sri).await } /// Copies cache data to a specified location. Returns the number of bytes @@ -235,7 +235,7 @@ where P: AsRef, K: AsRef, { - Ok(index::find_async(cache.as_ref(), key.as_ref()).await?) + index::find_async(cache.as_ref(), key.as_ref()).await } /// Returns true if the given hash exists in the cache. @@ -584,9 +584,9 @@ mod tests { let tmp = tempfile::tempdir().unwrap(); let dir = tmp.path(); let dest = dir.join("data"); - crate::write_sync(&dir, "my-key", b"hello world").unwrap(); + crate::write_sync(dir, "my-key", b"hello world").unwrap(); - crate::copy_sync(&dir, "my-key", &dest).unwrap(); + crate::copy_sync(dir, "my-key", &dest).unwrap(); let data = fs::read(&dest).unwrap(); assert_eq!(data, b"hello world"); } @@ -596,9 +596,9 @@ mod tests { let tmp = tempfile::tempdir().unwrap(); let dir = tmp.path(); let dest = dir.join("data"); - let sri = crate::write_sync(&dir, "my-key", b"hello world").unwrap(); + let sri = crate::write_sync(dir, "my-key", b"hello world").unwrap(); - crate::copy_hash_sync(&dir, &sri, &dest).unwrap(); + crate::copy_hash_sync(dir, &sri, &dest).unwrap(); let data = fs::read(&dest).unwrap(); assert_eq!(data, b"hello world"); } diff --git a/src/index.rs b/src/index.rs index 18c67ae..274c679 100644 --- a/src/index.rs +++ b/src/index.rs @@ -267,13 +267,13 @@ fn bucket_path(cache: &Path, key: &str) -> PathBuf { fn hash_key(key: &str) -> String { let mut hasher = Sha1::new(); - hasher.update(&key); + hasher.update(key); hex::encode(hasher.finalize()) } fn hash_entry(key: &str) -> String { let mut hasher = Sha256::new(); - hasher.update(&key); + hasher.update(key); hex::encode(hasher.finalize()) } diff --git a/src/rm.rs b/src/rm.rs index d0b1706..c185e3d 100644 --- a/src/rm.rs +++ b/src/rm.rs @@ -66,7 +66,7 @@ where /// } /// ``` pub async fn remove_hash>(cache: P, sri: &Integrity) -> Result<()> { - Ok(rm::rm_async(cache.as_ref(), sri).await?) + rm::rm_async(cache.as_ref(), sri).await } /// Removes entire contents of the cache, including temporary files, the entry