diff --git a/Cargo.toml b/Cargo.toml index ebd9f2b..97517e1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,6 +19,23 @@ homepage = "https://github.com/alloy-rs/trie" repository = "https://github.com/alloy-rs/trie" exclude = [".github/", "deny.toml", "release.toml", "rustfmt.toml"] +[lints.rust] +missing-debug-implementations = "warn" +missing-docs = "warn" +unreachable-pub = "warn" +unused-must-use = "deny" +rust-2018-idioms = "deny" +unnameable-types = "warn" + +[lints.rustdoc] +all = "warn" + +[lints.clippy] +all = { level = "warn", priority = -1 } +missing-const-for-fn = "warn" +use-self = "warn" +redundant-clone = "warn" + [dependencies] alloy-primitives = { version = "0.8.14", default-features = false, features = [ "rlp", diff --git a/benches/bench.rs b/benches/bench.rs index e7fead3..69e8dd7 100644 --- a/benches/bench.rs +++ b/benches/bench.rs @@ -1,3 +1,5 @@ +#![allow(missing_docs)] + use alloy_trie::nodes::encode_path_leaf; use criterion::{ criterion_group, criterion_main, measurement::WallTime, BenchmarkGroup, Criterion, diff --git a/src/proof/error.rs b/src/proof/error.rs index 497ecc9..93b0a54 100644 --- a/src/proof/error.rs +++ b/src/proof/error.rs @@ -34,7 +34,7 @@ impl std::error::Error for ProofVerificationError { fn source(&self) -> ::core::option::Option<&(dyn std::error::Error + 'static)> { #[allow(deprecated)] match self { - ProofVerificationError::Rlp { 0: transparent } => { + Self::Rlp { 0: transparent } => { std::error::Error::source(transparent as &dyn std::error::Error) } _ => None, @@ -45,22 +45,22 @@ impl std::error::Error for ProofVerificationError { impl fmt::Display for ProofVerificationError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - ProofVerificationError::RootMismatch { got, expected } => { + Self::RootMismatch { got, expected } => { write!(f, "root mismatch. got: {got}. expected: {expected}") } - ProofVerificationError::ValueMismatch { path, got, expected } => { + Self::ValueMismatch { path, got, expected } => { write!(f, "value mismatch at path {path:?}. got: {got:?}. expected: {expected:?}") } - ProofVerificationError::UnexpectedEmptyRoot => { + Self::UnexpectedEmptyRoot => { write!(f, "unexpected empty root node") } - ProofVerificationError::Rlp(error) => fmt::Display::fmt(error, f), + Self::Rlp(error) => fmt::Display::fmt(error, f), } } } impl From for ProofVerificationError { fn from(source: alloy_rlp::Error) -> Self { - ProofVerificationError::Rlp(source) + Self::Rlp(source) } } diff --git a/src/proof/verify.rs b/src/proof/verify.rs index c1e612d..ef1c531 100644 --- a/src/proof/verify.rs +++ b/src/proof/verify.rs @@ -101,8 +101,8 @@ impl Deref for NodeDecodingResult { fn deref(&self) -> &Self::Target { match self { - NodeDecodingResult::Node(node) => node.as_slice(), - NodeDecodingResult::Value(value) => value, + Self::Node(node) => node.as_slice(), + Self::Value(value) => value, } } } @@ -332,7 +332,7 @@ mod tests { assert_eq!( verify_proof( root, - target.clone(), + target, Some(value.to_vec()), proof.into_nodes_sorted().iter().map(|(_, node)| node) ), @@ -510,7 +510,7 @@ mod tests { }, { buffer.clear(); - TrieNode::Leaf(LeafNode::new(Nibbles::from_nibbles([0xb]), value.clone())) + TrieNode::Leaf(LeafNode::new(Nibbles::from_nibbles([0xb]), value)) .rlp(&mut buffer) }, ],