Skip to content

Commit

Permalink
Additional clippy lints from latest nightly (#219)
Browse files Browse the repository at this point in the history
  • Loading branch information
rkuris authored Aug 25, 2023
1 parent 1512fe6 commit f0f88c9
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 33 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ members = [
"firewood",
"fwdctl",
]
resolver = "2"

[profile.release]
debug = true
3 changes: 1 addition & 2 deletions firewood/src/merkle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
12 changes: 0 additions & 12 deletions firewood/src/nibbles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
3 changes: 1 addition & 2 deletions firewood/src/storage/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 2 additions & 4 deletions growth-ring/src/wal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,6 @@ impl<F: WalFile + 'static, S: WalStore<F>> WalFilePool<F, S> {
block_nbit: u64,
cache_size: NonZeroUsize,
) -> Result<Self, WalError> {
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 {
Expand Down Expand Up @@ -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);
Expand Down
6 changes: 2 additions & 4 deletions growth-ring/tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
8 changes: 3 additions & 5 deletions libaio/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -441,9 +441,7 @@ impl AioManager {

pub fn read(&self, fd: RawFd, offset: u64, length: usize, priority: Option<u16>) -> 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,
Expand Down Expand Up @@ -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()
Expand Down
4 changes: 0 additions & 4 deletions shale/src/cached.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ impl CachedStore for PlainMem {
offset: usize,
length: u64,
) -> Option<Box<dyn CachedView<DerefReturn = Vec<u8>>>> {
let offset = offset;
let length = length as usize;
if offset + length > self.space.read().unwrap().len() {
None
Expand All @@ -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);
Expand Down Expand Up @@ -116,7 +114,6 @@ impl CachedStore for DynamicMem {
offset: usize,
length: u64,
) -> Option<Box<dyn CachedView<DerefReturn = Vec<u8>>>> {
let offset = offset;
let length = length as usize;
let size = offset + length;
let mut space = self.space.write().unwrap();
Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit f0f88c9

Please sign in to comment.