Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Add clippy settings to Cargo.toml #71

Merged
merged 2 commits into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions benches/bench.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(missing_docs)]

use alloy_trie::nodes::encode_path_leaf;
use criterion::{
criterion_group, criterion_main, measurement::WallTime, BenchmarkGroup, Criterion,
Expand Down
12 changes: 6 additions & 6 deletions src/proof/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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<alloy_rlp::Error> for ProofVerificationError {
fn from(source: alloy_rlp::Error) -> Self {
ProofVerificationError::Rlp(source)
Self::Rlp(source)
}
}
8 changes: 4 additions & 4 deletions src/proof/verify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}
}
Expand Down Expand Up @@ -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)
),
Expand Down Expand Up @@ -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)
},
],
Expand Down
Loading