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

clippy: add unnested_or_patterns clippy lint #10526

Merged
merged 4 commits into from
Aug 26, 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
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ tuple_array_conversions = "warn"
type_repetition_in_bounds = "warn"
uninhabited_references = "warn"
unnecessary_struct_initialization = "warn"
unnested_or_patterns = "warn"
unused_peekable = "warn"
unused_rounding = "warn"
use_self = "warn"
Expand Down
2 changes: 1 addition & 1 deletion crates/metrics/metrics-derive/src/expand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ fn parse_metrics_attr(node: &DeriveInput) -> Result<MetricsAttr> {
}

let scope = match (scope, dynamic) {
(Some(scope), None) | (Some(scope), Some(false)) => MetricsScope::Static(scope),
(Some(scope), None | Some(false)) => MetricsScope::Static(scope),
(None, Some(true)) => MetricsScope::Dynamic,
(Some(_), Some(_)) => {
return Err(Error::new_spanned(node, "`scope = ..` conflicts with `dynamic = true`."))
Expand Down
57 changes: 27 additions & 30 deletions crates/net/network/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,7 @@ impl SessionError for EthStreamError {
fn merits_discovery_ban(&self) -> bool {
match self {
Self::P2PStreamError(P2PStreamError::HandshakeError(
P2PHandshakeError::HelloNotInHandshake,
)) |
Self::P2PStreamError(P2PStreamError::HandshakeError(
P2PHandshakeError::HelloNotInHandshake |
P2PHandshakeError::NonHelloMessageInHandshake,
)) => true,
Self::EthHandshakeError(err) => !matches!(err, EthHandshakeError::NoResponse),
Expand All @@ -126,29 +124,24 @@ impl SessionError for EthStreamError {
Self::P2PStreamError(err) => {
matches!(
err,
P2PStreamError::HandshakeError(P2PHandshakeError::NoSharedCapabilities) |
P2PStreamError::HandshakeError(P2PHandshakeError::HelloNotInHandshake) |
P2PStreamError::HandshakeError(
P2PHandshakeError::NonHelloMessageInHandshake
) |
P2PStreamError::HandshakeError(P2PHandshakeError::Disconnected(
DisconnectReason::UselessPeer
)) |
P2PStreamError::HandshakeError(P2PHandshakeError::Disconnected(
DisconnectReason::IncompatibleP2PProtocolVersion
)) |
P2PStreamError::HandshakeError(P2PHandshakeError::Disconnected(
DisconnectReason::ProtocolBreach
)) |
P2PStreamError::UnknownReservedMessageId(_) |
P2PStreamError::HandshakeError(
P2PHandshakeError::NoSharedCapabilities |
P2PHandshakeError::HelloNotInHandshake |
P2PHandshakeError::NonHelloMessageInHandshake |
P2PHandshakeError::Disconnected(
DisconnectReason::UselessPeer |
DisconnectReason::IncompatibleP2PProtocolVersion |
DisconnectReason::ProtocolBreach
)
) | P2PStreamError::UnknownReservedMessageId(_) |
P2PStreamError::EmptyProtocolMessage |
P2PStreamError::ParseSharedCapability(_) |
P2PStreamError::CapabilityNotShared |
P2PStreamError::Disconnected(DisconnectReason::UselessPeer) |
P2PStreamError::Disconnected(
DisconnectReason::IncompatibleP2PProtocolVersion
DisconnectReason::UselessPeer |
DisconnectReason::IncompatibleP2PProtocolVersion |
DisconnectReason::ProtocolBreach
) |
P2PStreamError::Disconnected(DisconnectReason::ProtocolBreach) |
P2PStreamError::MismatchedProtocolVersion { .. }
)
}
Expand Down Expand Up @@ -190,16 +183,20 @@ impl SessionError for EthStreamError {
match self {
// timeouts
Self::EthHandshakeError(EthHandshakeError::NoResponse) |
Self::P2PStreamError(P2PStreamError::HandshakeError(P2PHandshakeError::NoResponse)) |
Self::P2PStreamError(P2PStreamError::PingTimeout) => Some(BackoffKind::Low),
Self::P2PStreamError(
P2PStreamError::HandshakeError(P2PHandshakeError::NoResponse) |
P2PStreamError::PingTimeout,
) => Some(BackoffKind::Low),
// malformed messages
Self::P2PStreamError(P2PStreamError::Rlp(_)) |
Self::P2PStreamError(P2PStreamError::UnknownReservedMessageId(_)) |
Self::P2PStreamError(P2PStreamError::UnknownDisconnectReason(_)) |
Self::P2PStreamError(P2PStreamError::MessageTooBig { .. }) |
Self::P2PStreamError(P2PStreamError::EmptyProtocolMessage) |
Self::P2PStreamError(P2PStreamError::PingerError(_)) |
Self::P2PStreamError(P2PStreamError::Snap(_)) => Some(BackoffKind::Medium),
Self::P2PStreamError(
P2PStreamError::Rlp(_) |
P2PStreamError::UnknownReservedMessageId(_) |
P2PStreamError::UnknownDisconnectReason(_) |
P2PStreamError::MessageTooBig { .. } |
P2PStreamError::EmptyProtocolMessage |
P2PStreamError::PingerError(_) |
P2PStreamError::Snap(_),
) => Some(BackoffKind::Medium),
_ => None,
}
}
Expand Down
4 changes: 1 addition & 3 deletions crates/rpc/rpc-engine-api/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,8 @@ impl From<EngineApiError> for jsonrpsee_types::error::ErrorObject<'static> {
fn from(error: EngineApiError) -> Self {
match error {
EngineApiError::InvalidBodiesRange { .. } |
EngineApiError::EngineObjectValidationError(EngineObjectValidationError::Payload(
_,
)) |
EngineApiError::EngineObjectValidationError(
EngineObjectValidationError::Payload(_) |
EngineObjectValidationError::InvalidParams(_),
) => {
// Note: the data field is not required by the spec, but is also included by other
Expand Down
2 changes: 1 addition & 1 deletion crates/rpc/rpc-eth-types/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ impl From<EthApiError> for jsonrpsee_types::error::ErrorObject<'static> {
jsonrpsee_types::error::CALL_EXECUTION_FAILED_CODE,
err.to_string(),
),
err @ EthApiError::InternalBlockingTaskError | err @ EthApiError::InternalEthError => {
err @ (EthApiError::InternalBlockingTaskError | EthApiError::InternalEthError) => {
internal_rpc_err(err.to_string())
}
err @ EthApiError::TransactionInputError(_) => invalid_params_rpc_err(err.to_string()),
Expand Down
6 changes: 3 additions & 3 deletions crates/rpc/rpc-eth-types/src/logs_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ impl From<EthFilterError> for jsonrpsee_types::error::ErrorObject<'static> {
rpc_error_with_code(jsonrpsee_types::error::INTERNAL_ERROR_CODE, err.to_string())
}
EthFilterError::EthAPIError(err) => err.into(),
err @ EthFilterError::InvalidBlockRangeParams |
err @ EthFilterError::QueryExceedsMaxBlocks(_) |
err @ EthFilterError::QueryExceedsMaxResults(_) => {
err @ (EthFilterError::InvalidBlockRangeParams |
EthFilterError::QueryExceedsMaxBlocks(_) |
EthFilterError::QueryExceedsMaxResults(_)) => {
rpc_error_with_code(jsonrpsee_types::error::INVALID_PARAMS_CODE, err.to_string())
}
}
Expand Down
4 changes: 2 additions & 2 deletions crates/transaction-pool/src/pool/txpool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,10 @@ impl<T: TransactionOrdering> TxPool<T> {
std::mem::swap(&mut self.all_transactions.pending_fees.blob_fee, &mut pending_blob_fee);
match (self.all_transactions.pending_fees.blob_fee.cmp(&pending_blob_fee), base_fee_update)
{
(Ordering::Equal, Ordering::Equal) | (Ordering::Equal, Ordering::Greater) => {
(Ordering::Equal, Ordering::Equal | Ordering::Greater) => {
// fee unchanged, nothing to update
}
(Ordering::Greater, Ordering::Equal) | (Ordering::Greater, Ordering::Greater) => {
(Ordering::Greater, Ordering::Equal | Ordering::Greater) => {
// increased blob fee: recheck pending pool and remove all that are no longer valid
let removed =
self.pending_pool.update_blob_fee(self.all_transactions.pending_fees.blob_fee);
Expand Down
Loading