Skip to content

Commit

Permalink
chore: clippy, warnings (alloy-rs#504)
Browse files Browse the repository at this point in the history
  • Loading branch information
DaniPopes authored and ben186 committed Jul 27, 2024
1 parent 047f652 commit 58ca11b
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 16 deletions.
21 changes: 8 additions & 13 deletions crates/consensus/src/transaction/envelope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use crate::{
};
use alloy_eips::eip2718::{Decodable2718, Eip2718Error, Encodable2718};
use alloy_rlp::{Decodable, Encodable, Header};
use core::mem;

/// Ethereum `TransactionType` flags as specified in EIPs [2718], [1559], and
/// [2930].
Expand All @@ -28,25 +27,21 @@ pub enum TxType {
#[cfg(any(test, feature = "arbitrary"))]
impl<'a> arbitrary::Arbitrary<'a> for TxType {
fn arbitrary(u: &mut arbitrary::Unstructured<'_>) -> arbitrary::Result<Self> {
Ok(match u.int_in_range(0..=3)? {
0 => TxType::Legacy,
1 => TxType::Eip2930,
2 => TxType::Eip1559,
3 => TxType::Eip4844,
_ => unreachable!(),
})
Ok(u.int_in_range(0u8..=3)?.try_into().unwrap())
}
}

impl TryFrom<u8> for TxType {
type Error = Eip2718Error;

fn try_from(value: u8) -> Result<Self, Self::Error> {
match value {
// SAFETY: repr(u8) with explicit discriminant
0..=3 => Ok(unsafe { mem::transmute(value) }),
_ => Err(Eip2718Error::UnexpectedType(value)),
}
Ok(match value {
0 => TxType::Legacy,
1 => TxType::Eip2930,
2 => TxType::Eip1559,
3 => TxType::Eip4844,
_ => return Err(Eip2718Error::UnexpectedType(value)),
})
}
}

Expand Down
1 change: 1 addition & 0 deletions crates/contract/src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ mod tests {
sol! {
// solc v0.8.24; solc a.sol --via-ir --optimize --bin
#[sol(rpc, bytecode = "608080604052346100155760be908161001a8239f35b5f80fdfe60808060405260043610156011575f80fd5b5f3560e01c63299d8665146023575f80fd5b346084575f3660031901126084577f4e4cd44610926680098f1b54e2bdd1fb952659144c471173bbb9cf966af3a98860a0826060602a9452600560608201526468656c6c6f60d81b60808201526001602082015263deadbeef6040820152a2005b5f80fdfea2646970667358221220664e55b832143354f058e35b8948668184da14fcc5bf3300afb39dc6188c9add64736f6c63430008180033")]
#[allow(dead_code)]
contract MyContract {
#[derive(Debug, PartialEq)]
event MyEvent(uint64 indexed, string, bool, bytes32);
Expand Down
4 changes: 3 additions & 1 deletion crates/eips/src/eip4895.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
//!
//! [EIP-4895]: https://eips.ethereum.org/EIPS/eip-4895
#![allow(unknown_lints, non_local_definitions)]

use alloy_primitives::{Address, U256};
use alloy_rlp::{RlpDecodable, RlpEncodable};

Expand All @@ -11,7 +13,7 @@ pub const GWEI_TO_WEI: u64 = 1_000_000_000;
/// Withdrawal represents a validator withdrawal from the consensus layer.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash, RlpEncodable, RlpDecodable)]
#[cfg_attr(
all(any(test, feature = "arbitrary"), feature = "std"),
any(test, feature = "arbitrary"),
derive(proptest_derive::Arbitrary, arbitrary::Arbitrary)
)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
Expand Down
1 change: 0 additions & 1 deletion crates/eips/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
)]
#![deny(unused_must_use, rust_2018_idioms)]
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
#![cfg_attr(feature = "arbitrary", cfg(feature = "std"))]
#![cfg_attr(not(feature = "std"), no_std)]

#[allow(unused_imports)]
Expand Down
2 changes: 1 addition & 1 deletion crates/pubsub/src/managers/active_sub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::RawSubscription;
use alloy_json_rpc::SerializedRequest;
use alloy_primitives::B256;
use serde_json::value::RawValue;
use std::{fmt, hash::Hash, usize};
use std::{fmt, hash::Hash};
use tokio::sync::broadcast;

/// An active subscription.
Expand Down

0 comments on commit 58ca11b

Please sign in to comment.