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: nightly clippy #947

Merged
merged 1 commit into from
Jun 20, 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: 9 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,19 @@ repository = "https://github.com/alloy-rs/alloy"
exclude = ["benches/", "tests/"]

[workspace.lints]
rust.missing_debug_implementations = "warn"
rust.missing_docs = "warn"
rust.unreachable_pub = "warn"
rust.unused_must_use = "deny"
rust.rust_2018_idioms = "deny"
rust.missing-debug-implementations = "warn"
rust.missing-docs = "warn"
rust.unreachable-pub = "warn"
rust.unused-must-use = "deny"
rust.rust-2018-idioms = "deny"
rustdoc.all = "warn"

[workspace.lints.clippy]
all = "warn"
missing_const_for_fn = "warn"
use_self = "warn"
option_if_let_else = "warn"
missing-const-for-fn = "warn"
use-self = "warn"
option-if-let-else = "warn"
redundant-clone = "warn"

[workspace.metadata.docs.rs]
all-features = true
Expand Down
2 changes: 1 addition & 1 deletion crates/eip7547/src/summary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use std::fmt;
/// follows:
/// - `status`: `enum` - `"VALID" | "INVALID" | "SYNCING" | "ACCEPTED"`
/// - `validationError`: `String|null` - a message providing additional details on the validation
/// error if the payload is classified as `INVALID`.
/// error if the payload is classified as `INVALID`.
#[derive(Clone, Debug, PartialEq, Eq, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct InclusionListStatusV1 {
Expand Down
21 changes: 10 additions & 11 deletions crates/provider/src/fillers/gas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,16 @@ pub enum GasFillable {
/// ## Note:
///
/// The layer will populate gas fields based on the following logic:
/// - if `gas_price` is set, it will process as a legacy tx and populate the
/// `gas_limit` field if unset.
/// - if `access_list` is set, it will process as a 2930 tx and populate the
/// `gas_limit` and `gas_price` field if unset.
/// - if `blob_sidecar` is set, it will process as a 4844 tx and populate the
/// `gas_limit`, `max_fee_per_gas`, `max_priority_fee_per_gas` and
/// `max_fee_per_blob_gas` fields if unset.
/// - Otherwise, it will process as a EIP-1559 tx and populate the `gas_limit`,
/// `max_fee_per_gas` and `max_priority_fee_per_gas` fields if unset.
/// - If the network does not support EIP-1559, it will fallback to the legacy
/// tx and populate the `gas_limit` and `gas_price` fields if unset.
/// - if `gas_price` is set, it will process as a legacy tx and populate the `gas_limit` field if
/// unset.
/// - if `access_list` is set, it will process as a 2930 tx and populate the `gas_limit` and
/// `gas_price` field if unset.
/// - if `blob_sidecar` is set, it will process as a 4844 tx and populate the `gas_limit`,
/// `max_fee_per_gas`, `max_priority_fee_per_gas` and `max_fee_per_blob_gas` fields if unset.
/// - Otherwise, it will process as a EIP-1559 tx and populate the `gas_limit`, `max_fee_per_gas`
/// and `max_priority_fee_per_gas` fields if unset.
/// - If the network does not support EIP-1559, it will fallback to the legacy tx and populate the
/// `gas_limit` and `gas_price` fields if unset.
///
/// # Example
///
Expand Down
15 changes: 7 additions & 8 deletions crates/provider/src/fillers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,14 +120,13 @@ impl FillerControlFlow {
///
/// The [`FillerControlFlow`] determines the lifecycle of a filler. Fillers
/// may be in one of three states:
/// - **Missing**: The filler is missing a required property to fill in the
/// transaction request. [`TxFiller::status`] should return
/// [`FillerControlFlow::Missing`].
/// with a list of the missing properties.
/// - **Ready**: The filler is ready to fill in the transaction request.
/// [`TxFiller::status`] should return [`FillerControlFlow::Ready`].
/// - **Finished**: The filler has filled in all properties that it can fill.
/// [`TxFiller::status`] should return [`FillerControlFlow::Finished`].
/// - **Missing**: The filler is missing a required property to fill in the transaction request.
/// [`TxFiller::status`] should return [`FillerControlFlow::Missing`]. with a list of the missing
/// properties.
/// - **Ready**: The filler is ready to fill in the transaction request. [`TxFiller::status`] should
/// return [`FillerControlFlow::Ready`].
/// - **Finished**: The filler has filled in all properties that it can fill. [`TxFiller::status`]
/// should return [`FillerControlFlow::Finished`].
#[doc(alias = "TransactionFiller")]
pub trait TxFiller<N: Network = Ethereum>: Clone + Send + Sync + std::fmt::Debug {
/// The properties that this filler retrieves from the RPC. to fill in the
Expand Down
9 changes: 4 additions & 5 deletions crates/provider/src/fillers/nonce.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,10 @@ use tokio::sync::Mutex;
///
/// # Note
///
/// - If the transaction request does not have a sender set, this layer will
/// not fill nonces.
/// - Using two providers with their own nonce layer can potentially fill
/// invalid nonces if transactions are sent from the same address, as the next
/// nonce to be used is cached internally in the layer.
/// - If the transaction request does not have a sender set, this layer will not fill nonces.
/// - Using two providers with their own nonce layer can potentially fill invalid nonces if
/// transactions are sent from the same address, as the next nonce to be used is cached internally
/// in the layer.
///
/// # Example
///
Expand Down
2 changes: 1 addition & 1 deletion crates/provider/src/provider/root.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ impl<T, N> Clone for RootProviderInner<T, N> {
}

impl<T, N> RootProviderInner<T, N> {
pub(crate) fn new(client: RpcClient<T>) -> Self {
pub(crate) const fn new(client: RpcClient<T>) -> Self {
Self { client, heart: OnceLock::new(), _network: PhantomData }
}

Expand Down
16 changes: 8 additions & 8 deletions crates/provider/src/provider/with_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,44 +231,44 @@ where
}

/// Set the block id to "pending".
pub fn pending(self) -> Self {
pub const fn pending(self) -> Self {
self.block_id(BlockId::pending())
}

/// Set the block id to "latest".
pub fn latest(self) -> Self {
pub const fn latest(self) -> Self {
self.block_id(BlockId::latest())
}

/// Set the block id to "earliest".
pub fn earliest(self) -> Self {
pub const fn earliest(self) -> Self {
self.block_id(BlockId::earliest())
}

/// Set the block id to "finalized".
pub fn finalized(self) -> Self {
pub const fn finalized(self) -> Self {
self.block_id(BlockId::finalized())
}

/// Set the block id to "safe".
pub fn safe(self) -> Self {
pub const fn safe(self) -> Self {
self.block_id(BlockId::safe())
}

/// Set the block id to a specific height.
pub fn number(self, number: u64) -> Self {
pub const fn number(self, number: u64) -> Self {
self.block_id(BlockId::number(number))
}

/// Set the block id to a specific hash, without requiring the hash be part
/// of the canonical chain.
pub fn hash(self, hash: B256) -> Self {
pub const fn hash(self, hash: B256) -> Self {
self.block_id(BlockId::hash(hash))
}

/// Set the block id to a specific hash and require the hash be part of the
/// canonical chain.
pub fn hash_canonical(self, hash: B256) -> Self {
pub const fn hash_canonical(self, hash: B256) -> Self {
self.block_id(BlockId::hash_canonical(hash))
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/pubsub/src/sub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ impl<T: DeserializeOwned> From<Box<RawValue>> for SubscriptionItem<T> {
/// - The [`Subscription::recv_any`] and its variants will yield unexpected types as
/// [`SubscriptionItem::Other`].
/// - The [`Subscription::recv_result`] and its variants will attempt to deserialize the
/// notifications and yield the `serde_json::Result` of the deserialization.
/// notifications and yield the `serde_json::Result` of the deserialization.
#[derive(Debug)]
#[must_use]
pub struct Subscription<T> {
Expand Down
10 changes: 5 additions & 5 deletions crates/rpc-types-engine/src/payload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ impl fmt::Display for PayloadId {
/// This represents the `executionPayload` field in the return value of `engine_getPayloadV2`,
/// specified as:
///
/// - `executionPayload`: `ExecutionPayloadV1` | `ExecutionPayloadV2` where:
/// - `ExecutionPayloadV1` **MUST** be returned if the payload `timestamp` is lower than the
/// Shanghai timestamp
/// - `ExecutionPayloadV2` **MUST** be returned if the payload `timestamp` is greater or equal
/// to the Shanghai timestamp
/// - `executionPayload`: `ExecutionPayloadV1` | `ExecutionPayloadV2` where:
/// - `ExecutionPayloadV1` **MUST** be returned if the payload `timestamp` is lower than the
/// Shanghai timestamp
/// - `ExecutionPayloadV2` **MUST** be returned if the payload `timestamp` is greater or equal to
/// the Shanghai timestamp
///
/// See:
/// <https://github.com/ethereum/execution-apis/blob/fe8e13c288c592ec154ce25c534e26cb7ce0530d/src/engine/shanghai.md#response>
Expand Down
7 changes: 3 additions & 4 deletions crates/rpc-types-eth/src/filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,9 @@ impl<T: AsRef<[u8]> + Eq + Hash> FilterSet<T> {

impl<T: Clone + Eq + Hash> FilterSet<T> {
/// Returns a ValueOrArray inside an Option, so that:
/// - If the filter is empty, it returns None
/// - If the filter has only 1 value, it returns the single value
/// - Otherwise it returns an array of values
/// This should be useful for serialization
/// - If the filter is empty, it returns None
/// - If the filter has only 1 value, it returns the single value
/// - Otherwise it returns an array of values
pub fn to_value_or_array(&self) -> Option<ValueOrArray<T>> {
let mut values = self.0.iter().cloned().collect::<Vec<T>>();
match values.len() {
Expand Down
6 changes: 2 additions & 4 deletions crates/rpc-types-eth/src/transaction/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -364,10 +364,8 @@ impl TransactionRequest {
///
/// # Returns
///
/// - Ok(type) if all necessary keys are present to build the preferred
/// type.
/// - Err((type, missing)) if some keys are missing to build the preferred
/// type.
/// - Ok(type) if all necessary keys are present to build the preferred type.
/// - Err((type, missing)) if some keys are missing to build the preferred type.
pub fn missing_keys(&self) -> Result<TxType, (TxType, Vec<&'static str>)> {
let pref = self.preferred_type();
if let Err(missing) = match pref {
Expand Down
4 changes: 2 additions & 2 deletions crates/serde/src/other/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ pub struct OtherFields {
}

impl OtherFields {
/// Creates a new instance
pub fn new(inner: BTreeMap<String, serde_json::Value>) -> Self {
/// Creates a new [`OtherFields`] instance.
pub const fn new(inner: BTreeMap<String, serde_json::Value>) -> Self {
Self { inner }
}

Expand Down
5 changes: 3 additions & 2 deletions crates/serde/src/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ use serde::{Deserialize, Deserializer, Serialize};
/// `eth_getProof` also takes storage keys up to 32 bytes as input, so the `keys` field is
/// similarly deserialized. However, geth populates the storage proof `key` fields in the response
/// by mirroring the `key` field used in the input.
/// * See how `storageKey`s (the input) are populated in the `StorageResult` (the output):
/// <https://github.com/ethereum/go-ethereum/blob/00a73fbcce3250b87fc4160f3deddc44390848f4/internal/ethapi/api.go#L658-L690>
///
/// See how `storageKey`s (the input) are populated in the `StorageResult` (the output):
/// <https://github.com/ethereum/go-ethereum/blob/00a73fbcce3250b87fc4160f3deddc44390848f4/internal/ethapi/api.go#L658-L690>
///
/// The contained [B256] and From implementation for String are used to preserve the input and
/// implement this behavior from geth.
Expand Down