Skip to content

Commit

Permalink
Consolidate attributes (#466)
Browse files Browse the repository at this point in the history
  • Loading branch information
richardpringle authored Jan 3, 2024
1 parent 113ff2f commit 61c1236
Show file tree
Hide file tree
Showing 12 changed files with 20 additions and 55 deletions.
4 changes: 1 addition & 3 deletions firewood/src/merkle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1464,13 +1464,11 @@ pub const fn to_nibble_array(x: u8) -> [u8; 2] {
pub fn from_nibbles(nibbles: &[u8]) -> impl Iterator<Item = u8> + '_ {
debug_assert_eq!(nibbles.len() & 1, 0);
#[allow(clippy::indexing_slicing)]
#[allow(clippy::indexing_slicing)]
nibbles.chunks_exact(2).map(|p| (p[0] << 4) | p[1])
}

#[cfg(test)]
#[allow(clippy::unwrap_used)]
#[allow(clippy::indexing_slicing)]
#[allow(clippy::indexing_slicing, clippy::unwrap_used)]
mod tests {
use crate::merkle::node::PlainCodec;

Expand Down
3 changes: 1 addition & 2 deletions firewood/src/merkle/node/branch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,7 @@ impl BranchNode {
#[allow(clippy::indexing_slicing)]
if let Some(v) = &self.children_encoded[i] {
if v.len() == TRIE_HASH_LEN {
#[allow(clippy::indexing_slicing)]
#[allow(clippy::unwrap_used)]
#[allow(clippy::indexing_slicing, clippy::unwrap_used)]
(list[i] = Encoded::Data(
bincode::DefaultOptions::new().serialize(v).unwrap(),
));
Expand Down
12 changes: 2 additions & 10 deletions firewood/src/merkle/proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ impl<N: AsRef<[u8]> + Send> Proof<N> {

// Ensure the received batch is monotonic increasing and contains no deletions
#[allow(clippy::indexing_slicing)]
#[allow(clippy::indexing_slicing)]
if !keys.windows(2).all(|w| w[0].as_ref() < w[1].as_ref()) {
return Err(ProofError::NonMonotonicIncreaseRange);
}
Expand Down Expand Up @@ -631,10 +630,8 @@ fn unset_internal<K: AsRef<[u8]>, S: ShaleStore<Node> + Send + Sync, T: BinarySe
// If either the node pointed by left proof or right proof is nil,
// stop here and the forkpoint is the fullnode.
#[allow(clippy::indexing_slicing)]
#[allow(clippy::indexing_slicing)]
let left_node = n.chd()[left_chunks[index] as usize];
#[allow(clippy::indexing_slicing)]
#[allow(clippy::indexing_slicing)]
let right_node = n.chd()[right_chunks[index] as usize];

match (left_node.as_ref(), right_node.as_ref()) {
Expand Down Expand Up @@ -704,17 +701,13 @@ fn unset_internal<K: AsRef<[u8]>, S: ShaleStore<Node> + Send + Sync, T: BinarySe

match &u_ref.inner() {
NodeType::Branch(n) => {
#[allow(clippy::indexing_slicing)]
#[allow(clippy::indexing_slicing)]
let left_node = n.chd()[left_chunks[index] as usize];
#[allow(clippy::indexing_slicing)]
#[allow(clippy::indexing_slicing)]
let right_node = n.chd()[right_chunks[index] as usize];

// unset all internal nodes calculated encoded value in the forkpoint
#[allow(clippy::unwrap_used)]
#[allow(clippy::indexing_slicing)]
#[allow(clippy::indexing_slicing)]
#[allow(clippy::indexing_slicing, clippy::unwrap_used)]
for i in left_chunks[index] + 1..right_chunks[index] {
u_ref
.write(|u| {
Expand Down Expand Up @@ -967,8 +960,7 @@ fn unset_node_ref<K: AsRef<[u8]>, S: ShaleStore<Node> + Send + Sync, T: BinarySe
(true, Ordering::Less) | (false, Ordering::Greater)
);

#[allow(clippy::unwrap_used)]
#[allow(clippy::indexing_slicing)]
#[allow(clippy::indexing_slicing, clippy::unwrap_used)]
if should_unset_entire_branch {
p_ref
.write(|p| {
Expand Down
3 changes: 1 addition & 2 deletions firewood/src/merkle/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -413,8 +413,7 @@ impl<T: Iterator<Item = u8>> IntoBytes for T {}
use super::tests::create_test_merkle;

#[cfg(test)]
#[allow(clippy::unwrap_used)]
#[allow(clippy::indexing_slicing)]
#[allow(clippy::indexing_slicing, clippy::unwrap_used)]
mod tests {
use crate::nibbles::Nibbles;

Expand Down
3 changes: 1 addition & 2 deletions firewood/src/merkle/trie_hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ impl Storable for TrieHash {
offset: addr,
size: U64_TRIE_HASH_LEN,
})?;
#[allow(clippy::unwrap_used)]
#[allow(clippy::indexing_slicing)]
#[allow(clippy::indexing_slicing, clippy::unwrap_used)]
Ok(Self(raw.as_deref()[..TRIE_HASH_LEN].try_into().unwrap()))
}

Expand Down
2 changes: 0 additions & 2 deletions firewood/src/nibbles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,10 @@ impl<'a, const LEADING_ZEROES: usize> Index<usize> for Nibbles<'a, LEADING_ZEROE
_ if index < LEADING_ZEROES => &NIBBLES[0],
_ if (index - LEADING_ZEROES) % 2 == 0 =>
{
#[allow(clippy::indexing_slicing)]
#[allow(clippy::indexing_slicing)]
&NIBBLES[(self.0[(index - LEADING_ZEROES) / 2] >> 4) as usize]
}
#[allow(clippy::indexing_slicing)]
#[allow(clippy::indexing_slicing)]
_ => &NIBBLES[(self.0[(index - LEADING_ZEROES) / 2] & 0xf) as usize],
}
}
Expand Down
9 changes: 3 additions & 6 deletions firewood/src/shale/cached.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,7 @@ impl CachedView for PlainMemView {
type DerefReturn = Vec<u8>;

fn as_deref(&self) -> Self::DerefReturn {
#[allow(clippy::unwrap_used)]
#[allow(clippy::indexing_slicing)]
#[allow(clippy::indexing_slicing, clippy::unwrap_used)]
self.mem.space.read().unwrap()[self.offset..self.offset + self.length].to_vec()
}
}
Expand Down Expand Up @@ -195,15 +194,13 @@ impl CachedView for DynamicMemView {
type DerefReturn = Vec<u8>;

fn as_deref(&self) -> Self::DerefReturn {
#[allow(clippy::unwrap_used)]
#[allow(clippy::indexing_slicing)]
#[allow(clippy::indexing_slicing, clippy::unwrap_used)]
self.mem.space.read().unwrap()[self.offset..self.offset + self.length].to_vec()
}
}

#[cfg(test)]
#[allow(clippy::unwrap_used)]
#[allow(clippy::indexing_slicing)]
#[allow(clippy::indexing_slicing, clippy::unwrap_used)]
mod tests {
use super::*;

Expand Down
3 changes: 1 addition & 2 deletions firewood/src/shale/compact.rs
Original file line number Diff line number Diff line change
Expand Up @@ -650,8 +650,7 @@ impl<T: Storable + 'static, M: CachedStore + Send + Sync> ShaleStore<T> for Comp
}

#[cfg(test)]
#[allow(clippy::unwrap_used)]
#[allow(clippy::indexing_slicing)]
#[allow(clippy::indexing_slicing, clippy::unwrap_used)]
mod tests {
use sha3::Digest;

Expand Down
12 changes: 4 additions & 8 deletions firewood/src/storage/buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,7 @@ fn schedule_write(
let offset = page_key.1 << PAGE_SIZE_NBIT;
let fid = offset >> p.file_nbit;
let fmask = (1 << p.file_nbit) - 1;
#[allow(clippy::unwrap_used)]
#[allow(clippy::indexing_slicing)]
#[allow(clippy::unwrap_used, clippy::indexing_slicing)]
let file = file_pools.borrow()[page_key.0 as usize]
.as_ref()
.unwrap()
Expand Down Expand Up @@ -302,8 +301,7 @@ async fn init_wal(
for (undo, redo) in ash.iter() {
let offset = undo.offset;
let file_pools = file_pools.borrow();
#[allow(clippy::unwrap_used)]
#[allow(clippy::indexing_slicing)]
#[allow(clippy::unwrap_used, clippy::indexing_slicing)]
let file_pool = file_pools[space_id as usize].as_ref().unwrap();
let file_nbit = file_pool.get_file_nbit();
let file_mask = (1 << file_nbit) - 1;
Expand Down Expand Up @@ -395,8 +393,7 @@ async fn run_wal_queue(
false
}
Vacant(e) => {
#[allow(clippy::unwrap_used)]
#[allow(clippy::indexing_slicing)]
#[allow(clippy::unwrap_used, clippy::indexing_slicing)]
let file_nbit = file_pools.borrow()[page_key.0 as usize]
.as_ref()
.unwrap()
Expand Down Expand Up @@ -636,8 +633,7 @@ impl DiskBufferRequester {
}

#[cfg(test)]
#[allow(clippy::unwrap_used)]
#[allow(clippy::indexing_slicing)]
#[allow(clippy::unwrap_used, clippy::indexing_slicing)]
mod tests {
use sha3::Digest;
use std::path::{Path, PathBuf};
Expand Down
12 changes: 2 additions & 10 deletions firewood/src/storage/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,7 @@ impl StoreDelta {
widx.sort_by_key(|i| writes[*i].offset);

let mut witer = widx.into_iter();
#[allow(clippy::unwrap_used)]
#[allow(clippy::indexing_slicing)]
#[allow(clippy::indexing_slicing, clippy::unwrap_used)]
let w0 = &writes[witer.next().unwrap()];
let mut head = w0.offset >> PAGE_SIZE_NBIT;
let mut tail = (w0.offset + w0.data.len() as u64 - 1) >> PAGE_SIZE_NBIT;
Expand Down Expand Up @@ -213,7 +212,6 @@ impl StoreDelta {
if !data.is_empty() {
l += 1;
#[allow(clippy::indexing_slicing)]
#[allow(clippy::indexing_slicing)]
deltas[l].data_mut()[..data.len()].copy_from_slice(data);
}
}
Expand Down Expand Up @@ -274,11 +272,8 @@ impl MemStoreR for StoreRev {
#[allow(clippy::indexing_slicing)]
data.extend(base_space.get_slice(start, delta[l].offset() - start)?);
#[allow(clippy::indexing_slicing)]
#[allow(clippy::indexing_slicing)]
data.extend(&delta[l].data()[..p_off as usize]);
} else {
#[allow(clippy::indexing_slicing)]
#[allow(clippy::indexing_slicing)]
#[allow(clippy::indexing_slicing)]
data.extend(&delta[l].data()[(start - delta[l].offset()) as usize..p_off as usize]);
};
Expand All @@ -298,8 +293,6 @@ impl MemStoreR for StoreRev {
}
#[allow(clippy::indexing_slicing)]
if end < delta[l].offset() + PAGE_SIZE {
#[allow(clippy::indexing_slicing)]
#[allow(clippy::indexing_slicing)]
#[allow(clippy::indexing_slicing)]
data.extend(&delta[l].data()[..(end - delta[l].offset()) as usize]);
break;
Expand Down Expand Up @@ -655,8 +648,7 @@ impl MemStoreR for ZeroStore {
}

#[cfg(test)]
#[allow(clippy::unwrap_used)]
#[allow(clippy::indexing_slicing)]
#[allow(clippy::unwrap_used, clippy::indexing_slicing)]
mod test {
use super::*;
#[test]
Expand Down
3 changes: 1 addition & 2 deletions firewood/tests/merkle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,7 @@ fn test_root_hash_random_deletions() -> Result<(), DataStoreError> {
}

#[test]
#[allow(clippy::unwrap_used)]
#[allow(clippy::indexing_slicing)]
#[allow(clippy::unwrap_used, clippy::indexing_slicing)]
fn test_proof() -> Result<(), DataStoreError> {
let set = generate_random_data(500);
let mut items = Vec::from_iter(set.iter());
Expand Down
9 changes: 3 additions & 6 deletions grpc-testtool/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,17 @@
// See the file LICENSE.md for licensing terms.

pub mod sync {
#![allow(clippy::unwrap_used)]
#![allow(clippy::missing_const_for_fn)]
#![allow(clippy::unwrap_used, clippy::missing_const_for_fn)]
tonic::include_proto!("sync");
}

pub mod rpcdb {
#![allow(clippy::unwrap_used)]
#![allow(clippy::missing_const_for_fn)]
#![allow(clippy::unwrap_used, clippy::missing_const_for_fn)]
tonic::include_proto!("rpcdb");
}

pub mod process_server {
#![allow(clippy::unwrap_used)]
#![allow(clippy::missing_const_for_fn)]
#![allow(clippy::unwrap_used, clippy::missing_const_for_fn)]
tonic::include_proto!("process");
}

Expand Down

0 comments on commit 61c1236

Please sign in to comment.