Activate clippy::manual_let_else lint (#4889)

## Issue Addressed

#4888

## Proposed Changes

Enabled `clippy::manual_let_else` lint and resolved the warning messages.
This commit is contained in:
Eitan Seri-Levi
2023-10-31 10:31:02 +00:00
parent a9f9dc241d
commit 4ce01ddd11
35 changed files with 185 additions and 286 deletions

View File

@@ -135,9 +135,8 @@ impl<TSpec: EthSpec> Decoder for SSZSnappyInboundCodec<TSpec> {
if self.protocol.versioned_protocol == SupportedProtocol::MetaDataV2 {
return Ok(Some(InboundRequest::MetaData(MetadataRequest::new_v2())));
}
let length = match handle_length(&mut self.inner, &mut self.len, src)? {
Some(len) => len,
None => return Ok(None),
let Some(length) = handle_length(&mut self.inner, &mut self.len, src)? else {
return Ok(None);
};
// Should not attempt to decode rpc chunks with `length > max_packet_size` or not within bounds of
@@ -277,9 +276,8 @@ impl<TSpec: EthSpec> Decoder for SSZSnappyOutboundCodec<TSpec> {
return Ok(None);
}
}
let length = match handle_length(&mut self.inner, &mut self.len, src)? {
Some(len) => len,
None => return Ok(None),
let Some(length) = handle_length(&mut self.inner, &mut self.len, src)? else {
return Ok(None);
};
// Should not attempt to decode rpc chunks with `length > max_packet_size` or not within bounds of
@@ -324,9 +322,8 @@ impl<TSpec: EthSpec> OutboundCodec<OutboundRequest<TSpec>> for SSZSnappyOutbound
&mut self,
src: &mut BytesMut,
) -> Result<Option<Self::CodecErrorType>, RPCError> {
let length = match handle_length(&mut self.inner, &mut self.len, src)? {
Some(len) => len,
None => return Ok(None),
let Some(length) = handle_length(&mut self.inner, &mut self.len, src)? else {
return Ok(None);
};
// Should not attempt to decode rpc chunks with `length > max_packet_size` or not within bounds of

View File

@@ -286,9 +286,7 @@ where
// wrong state a response will fail silently.
fn send_response(&mut self, inbound_id: SubstreamId, response: RPCCodedResponse<TSpec>) {
// check if the stream matching the response still exists
let inbound_info = if let Some(info) = self.inbound_substreams.get_mut(&inbound_id) {
info
} else {
let Some(inbound_info) = self.inbound_substreams.get_mut(&inbound_id) else {
if !matches!(response, RPCCodedResponse::StreamTermination(..)) {
// the stream is closed after sending the expected number of responses
trace!(self.log, "Inbound stream has expired. Response not sent";
@@ -296,7 +294,6 @@ where
}
return;
};
// If the response we are sending is an error, report back for handling
if let RPCCodedResponse::Error(ref code, ref reason) = response {
self.events_out.push(Err(HandlerErr::Inbound {

View File

@@ -205,9 +205,8 @@ impl GossipCache {
GossipKind::LightClientFinalityUpdate => self.light_client_finality_update,
GossipKind::LightClientOptimisticUpdate => self.light_client_optimistic_update,
};
let expire_timeout = match expire_timeout {
Some(expire_timeout) => expire_timeout,
None => return,
let Some(expire_timeout) = expire_timeout else {
return;
};
match self
.topic_msgs