From f0f88c962e625283f68ab74582ca27277c4ee782 Mon Sep 17 00:00:00 2001 From: Ron Kuris Date: Fri, 25 Aug 2023 12:57:59 -0400 Subject: [PATCH] Additional clippy lints from latest nightly (#219) --- Cargo.toml | 1 + firewood/src/merkle.rs | 3 +-- firewood/src/nibbles.rs | 12 ------------ firewood/src/storage/mod.rs | 3 +-- growth-ring/src/wal.rs | 6 ++---- growth-ring/tests/common/mod.rs | 6 ++---- libaio/src/lib.rs | 8 +++----- shale/src/cached.rs | 4 ---- 8 files changed, 10 insertions(+), 33 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index a1d8190ae..8ede346b7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,6 +6,7 @@ members = [ "firewood", "fwdctl", ] +resolver = "2" [profile.release] debug = true diff --git a/firewood/src/merkle.rs b/firewood/src/merkle.rs index 64b32df1c..c4bf139a0 100644 --- a/firewood/src/merkle.rs +++ b/firewood/src/merkle.rs @@ -1318,8 +1318,7 @@ mod test { #[test] fn test_merkle_node_encoding() { let check = |node: Node| { - let mut bytes = Vec::new(); - bytes.resize(node.dehydrated_len() as usize, 0); + let mut bytes = vec![0; node.dehydrated_len() as usize]; node.dehydrate(&mut bytes).unwrap(); let mut mem = PlainMem::new(bytes.len() as u64, 0x0); diff --git a/firewood/src/nibbles.rs b/firewood/src/nibbles.rs index 5f65caf06..7837a8e1a 100644 --- a/firewood/src/nibbles.rs +++ b/firewood/src/nibbles.rs @@ -130,12 +130,6 @@ mod test { expected.into_iter().eq(nib.iter()); } - #[test] - fn skip_zero() { - let nib = Nibbles::<0>(&TEST_BYTES); - assert!(nib.iter().skip(0).eq(nib.iter())); - } - #[test] fn skip_skips_zeroes() { let nib1 = Nibbles::<1>(&TEST_BYTES); @@ -150,12 +144,6 @@ mod test { let _ = nib[8]; } - #[test] - fn skip_before_zeroes() { - let nib = Nibbles::<1>(&TEST_BYTES); - assert!(nib.iter().skip(0).eq(nib.iter())); - } - #[test] fn last_nibble() { let nib = Nibbles::<0>(&TEST_BYTES); diff --git a/firewood/src/storage/mod.rs b/firewood/src/storage/mod.rs index 73163e26c..b79f91702 100644 --- a/firewood/src/storage/mod.rs +++ b/firewood/src/storage/mod.rs @@ -655,8 +655,7 @@ fn test_from_ash() { let max = rng.gen_range(min + PAGE_SIZE..min + 100 * PAGE_SIZE); for _ in 0..20 { let n = 20; - let mut canvas = Vec::new(); - canvas.resize((max - min) as usize, 0); + let mut canvas = vec![0; (max - min) as usize]; let mut writes: Vec<_> = Vec::new(); for _ in 0..n { let l = rng.gen_range(min..max); diff --git a/growth-ring/src/wal.rs b/growth-ring/src/wal.rs index 8b7de8c29..7208102d1 100644 --- a/growth-ring/src/wal.rs +++ b/growth-ring/src/wal.rs @@ -254,8 +254,6 @@ impl> WalFilePool { block_nbit: u64, cache_size: NonZeroUsize, ) -> Result { - let file_nbit = file_nbit; - let block_nbit = block_nbit; let header_file = store.open_file("HEAD", true).await?; header_file.truncate(HEADER_SIZE).await?; Ok(WalFilePool { @@ -1131,8 +1129,8 @@ impl WalLoader { die!() } chunks.push(chunk); - let mut payload = Vec::new(); - payload.resize(chunks.iter().fold(0, |acc, v| acc + v.len()), 0); + let mut payload = + vec![0; chunks.iter().fold(0, |acc, v| acc + v.len())]; let mut ps = &mut payload[..]; for c in chunks { ps[..c.len()].copy_from_slice(&c); diff --git a/growth-ring/tests/common/mod.rs b/growth-ring/tests/common/mod.rs index a7580d67d..fe21dd299 100644 --- a/growth-ring/tests/common/mod.rs +++ b/growth-ring/tests/common/mod.rs @@ -331,10 +331,8 @@ pub struct Canvas { impl Canvas { pub fn new(size: usize) -> Self { - let mut canvas = Vec::new(); - // fill the backgroudn color 0 - canvas.resize(size, 0); - let canvas = canvas.into_boxed_slice(); + let canvas = vec![0; size].into_boxed_slice(); + // fill the background color 0 Canvas { waiting: HashMap::new(), queue: IndexMap::new(), diff --git a/libaio/src/lib.rs b/libaio/src/lib.rs index 37ce82def..2bb8a8021 100644 --- a/libaio/src/lib.rs +++ b/libaio/src/lib.rs @@ -441,9 +441,7 @@ impl AioManager { pub fn read(&self, fd: RawFd, offset: u64, length: usize, priority: Option) -> AioFuture { let priority = priority.unwrap_or(0); - let mut data = Vec::new(); - data.resize(length, 0); - let data = data.into_boxed_slice(); + let data = vec![0; length].into_boxed_slice(); let aio = Aio::new( self.scheduler_in.next_id(), fd, @@ -481,8 +479,8 @@ impl AioManager { let w = self.notifier.waiting.lock(); w.get(&aio_id).map(|state| { match state { - AioState::FutureInit(aio, _) => &**aio.data.as_ref().unwrap(), - AioState::FuturePending(aio, _, _) => &**aio.data.as_ref().unwrap(), + AioState::FutureInit(aio, _) => aio.data.as_ref().unwrap(), + AioState::FuturePending(aio, _, _) => aio.data.as_ref().unwrap(), AioState::FutureDone(res) => &res.1, } .to_vec() diff --git a/shale/src/cached.rs b/shale/src/cached.rs index 8963ce665..15b7edf62 100644 --- a/shale/src/cached.rs +++ b/shale/src/cached.rs @@ -29,7 +29,6 @@ impl CachedStore for PlainMem { offset: usize, length: u64, ) -> Option>>> { - let offset = offset; let length = length as usize; if offset + length > self.space.read().unwrap().len() { None @@ -53,7 +52,6 @@ impl CachedStore for PlainMem { } fn write(&mut self, offset: usize, change: &[u8]) { - let offset = offset; let length = change.len(); let mut vect = self.space.deref().write().unwrap(); vect.as_mut_slice()[offset..offset + length].copy_from_slice(change); @@ -116,7 +114,6 @@ impl CachedStore for DynamicMem { offset: usize, length: u64, ) -> Option>>> { - let offset = offset; let length = length as usize; let size = offset + length; let mut space = self.space.write().unwrap(); @@ -144,7 +141,6 @@ impl CachedStore for DynamicMem { } fn write(&mut self, offset: usize, change: &[u8]) { - let offset = offset; let length = change.len(); let size = offset + length;