mirror of
https://github.com/neondatabase/neon.git
synced 2025-12-22 21:59:59 +00:00
chore: fix clippy lints from nightly-2025-03-16 (#11273)
I like to run nightly clippy every so often to make our future rust upgrades easier. Some notable changes: * Prefer `next_back()` over `last()`. Generic iterators will implement `last()` to run forward through the iterator until the end. * Prefer `io::Error::other()`. * Use implicit returns One case where I haven't dealt with the issues is the now [more-sensitive "large enum variant" lint](https://github.com/rust-lang/rust-clippy/pull/13833). I chose not to take any decisions around it here, and simply marked them as allow for now.
This commit is contained in:
@@ -96,6 +96,7 @@ enum Message {
|
||||
|
||||
impl Message {
|
||||
/// Convert proto message to internal message.
|
||||
#[allow(clippy::result_large_err, reason = "TODO")]
|
||||
pub fn from(proto_msg: TypedMessage) -> Result<Self, Status> {
|
||||
match proto_msg.r#type() {
|
||||
MessageType::SafekeeperTimelineInfo => Ok(Message::SafekeeperTimelineInfo(
|
||||
@@ -127,6 +128,7 @@ impl Message {
|
||||
}
|
||||
|
||||
/// Get the tenant_timeline_id from the message.
|
||||
#[allow(clippy::result_large_err, reason = "TODO")]
|
||||
pub fn tenant_timeline_id(&self) -> Result<Option<TenantTimelineId>, Status> {
|
||||
match self {
|
||||
Message::SafekeeperTimelineInfo(msg) => Ok(msg
|
||||
@@ -185,6 +187,7 @@ enum SubscriptionKey {
|
||||
|
||||
impl SubscriptionKey {
|
||||
/// Parse protobuf subkey (protobuf doesn't have fixed size bytes, we get vectors).
|
||||
#[allow(clippy::result_large_err, reason = "TODO")]
|
||||
pub fn from_proto_subscription_key(key: ProtoSubscriptionKey) -> Result<Self, Status> {
|
||||
match key {
|
||||
ProtoSubscriptionKey::All(_) => Ok(SubscriptionKey::All),
|
||||
@@ -195,6 +198,7 @@ impl SubscriptionKey {
|
||||
}
|
||||
|
||||
/// Parse from FilterTenantTimelineId
|
||||
#[allow(clippy::result_large_err, reason = "TODO")]
|
||||
pub fn from_proto_filter_tenant_timeline_id(
|
||||
opt: Option<&FilterTenantTimelineId>,
|
||||
) -> Result<Self, Status> {
|
||||
@@ -385,6 +389,7 @@ impl Registry {
|
||||
}
|
||||
|
||||
/// Send msg to relevant subscribers.
|
||||
#[allow(clippy::result_large_err, reason = "TODO")]
|
||||
pub fn send_msg(&self, msg: &Message) -> Result<(), Status> {
|
||||
PROCESSED_MESSAGES_TOTAL.inc();
|
||||
|
||||
@@ -436,6 +441,7 @@ struct Publisher {
|
||||
|
||||
impl Publisher {
|
||||
/// Send msg to relevant subscribers.
|
||||
#[allow(clippy::result_large_err, reason = "TODO")]
|
||||
pub fn send_msg(&mut self, msg: &Message) -> Result<(), Status> {
|
||||
self.registry.send_msg(msg)
|
||||
}
|
||||
|
||||
@@ -79,6 +79,7 @@ impl BrokerClientChannel {
|
||||
}
|
||||
|
||||
// parse variable length bytes from protobuf
|
||||
#[allow(clippy::result_large_err, reason = "TODO")]
|
||||
pub fn parse_proto_ttid(proto_ttid: &ProtoTenantTimelineId) -> Result<TenantTimelineId, Status> {
|
||||
let tenant_id = TenantId::from_slice(&proto_ttid.tenant_id)
|
||||
.map_err(|e| Status::new(Code::InvalidArgument, format!("malformed tenant_id: {}", e)))?;
|
||||
|
||||
Reference in New Issue
Block a user