chore: address Rust 1.92.0 clippy lints (#10756)

This commit is contained in:
Sanchith Hegde
2025-12-22 18:18:25 +05:30
committed by GitHub
parent a3f2b6ce6f
commit 85f23ecea7
24 changed files with 24 additions and 124 deletions

1
Cargo.lock generated
View File

@@ -3124,7 +3124,6 @@ checksum = "27a72baa257b5e0e2de241967bc5ee8f855d6072351042688621081d66b2a76b"
dependencies = [
"anyhow",
"rustc_version 0.4.1",
"serde",
]
[[package]]

View File

@@ -370,7 +370,7 @@ impl<T: AnalyticsDataSource> ToSql<T> for FilterCombinator {
#[derive(Debug, Clone)]
pub enum Filter {
Plain(String, FilterTypes, String),
NestedFilter(FilterCombinator, Vec<Filter>),
NestedFilter(FilterCombinator, Vec<Self>),
}
impl Default for Filter {

View File

@@ -10,7 +10,6 @@ license.workspace = true
[features]
errors = ["dep:actix-web", "dep:reqwest"]
dummy_connector = ["euclid/dummy_connector", "common_enums/dummy_connector"]
detailed_errors = []
payouts = ["common_enums/payouts"]
frm = []
olap = []

View File

@@ -16,8 +16,6 @@ pub struct ApiError {
pub error_identifier: u16,
pub error_message: String,
pub extra: Option<Extra>,
#[cfg(feature = "detailed_errors")]
pub stacktrace: Option<serde_json::Value>,
}
impl ApiError {
@@ -32,8 +30,6 @@ impl ApiError {
error_identifier,
error_message: error_message.to_string(),
extra,
#[cfg(feature = "detailed_errors")]
stacktrace: None,
}
}
}
@@ -59,10 +55,6 @@ pub struct ErrorResponse {
pub code: String,
#[serde(flatten)]
pub extra: Option<Extra>,
#[cfg(feature = "detailed_errors")]
#[serde(skip_serializing_if = "Option::is_none")]
pub stacktrace: Option<serde_json::Value>,
}
impl From<&ApiErrorResponse> for ErrorResponse {
@@ -74,9 +66,6 @@ impl From<&ApiErrorResponse> for ErrorResponse {
message: error_info.error_message.clone(),
error_type,
extra: error_info.extra.clone(),
#[cfg(feature = "detailed_errors")]
stacktrace: error_info.stacktrace.clone(),
}
}
}

View File

@@ -14,7 +14,7 @@ use common_utils::{
};
use masking::PeekInterface;
use serde::de;
use utoipa::{schema, ToSchema};
use utoipa::ToSchema;
#[cfg(feature = "v1")]
use crate::payments::BankCodeResponse;

View File

@@ -730,8 +730,6 @@ macro_rules! impl_enum_str {
mod tests {
use serde_json::{json, Value as JsonValue};
use crate::impl_enum_str;
impl_enum_str!(
tag_delimiter = ":",
#[derive(Debug, PartialEq, Clone)]

View File

@@ -246,11 +246,9 @@ mod tests {
use hyperswitch_constraint_graph as cgraph;
use super::*;
use crate::{
dirval,
dssa::graph::{self, euclid_graph_prelude},
types::DummyOutput,
};
#[allow(unused_imports)] // Required by the `knowledge!` macro expansion
use crate::dssa::graph::euclid_graph_prelude;
use crate::{dirval, dssa::graph, types::DummyOutput};
#[test]
fn test_conflicting_assertion_detection() {

View File

@@ -2,7 +2,9 @@ use std::sync::LazyLock;
use euclid_macros::knowledge;
use crate::{dssa::graph::euclid_graph_prelude, frontend::dir};
#[allow(unused_imports)] // Required by the `knowledge!` macro expansion
use crate::dssa::graph::euclid_graph_prelude;
use crate::frontend::dir;
pub static ANALYSIS_GRAPH: LazyLock<hyperswitch_constraint_graph::ConstraintGraph<dir::DirValue>> =
LazyLock::new(|| {

View File

@@ -120,7 +120,7 @@ pub type IfCondition = Vec<Comparison>;
pub struct IfStatement {
#[schema(value_type=Vec<Comparison>)]
pub condition: IfCondition,
pub nested: Option<Vec<IfStatement>>,
pub nested: Option<Vec<Self>>,
}
/// Represents a rule

View File

@@ -960,7 +960,7 @@ pub type DirIfCondition = Vec<DirComparison>;
#[derive(Debug, Clone)]
pub struct DirIfStatement {
pub condition: DirIfCondition,
pub nested: Option<Vec<DirIfStatement>>,
pub nested: Option<Vec<Self>>,
}
#[derive(Debug, Clone)]

View File

@@ -21,7 +21,7 @@ pub type ValuedIfCondition = Vec<ValuedComparison>;
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct ValuedIfStatement {
pub condition: ValuedIfCondition,
pub nested: Option<Vec<ValuedIfStatement>>,
pub nested: Option<Vec<Self>>,
}
#[derive(Clone, Debug, Serialize, Deserialize)]

View File

@@ -21,13 +21,13 @@ pub enum AnalysisTrace<V: ValueNode> {
},
AllAggregation {
unsatisfied: Vec<Weak<AnalysisTrace<V>>>,
unsatisfied: Vec<Weak<Self>>,
info: Option<&'static str>,
metadata: Option<Arc<dyn Metadata>>,
},
AnyAggregation {
unsatisfied: Vec<Weak<AnalysisTrace<V>>>,
unsatisfied: Vec<Weak<Self>>,
info: Option<&'static str>,
metadata: Option<Arc<dyn Metadata>>,
},

View File

@@ -1264,9 +1264,7 @@ where
Some(connector) => Some(diesel_models::types::PaymentRevenueRecoveryMetadata {
// Update retry count by one.
total_retry_count: revenue_recovery.as_ref().map_or(
self.revenue_recovery_data
.retry_count
.map_or_else(|| 1, |retry_count| retry_count),
self.revenue_recovery_data.retry_count.unwrap_or(1),
|data| (data.total_retry_count + 1),
),
// Since this is an external system call, marking this payment_connector_transmission to ConnectorCallSucceeded.

View File

@@ -28,7 +28,6 @@ accounts_cache = ["storage_impl/accounts_cache"]
vergen = ["router_env/vergen"]
dummy_connector = ["api_models/dummy_connector", "euclid/dummy_connector", "hyperswitch_interfaces/dummy_connector", "kgraph_utils/dummy_connector", "payment_methods/dummy_connector", "hyperswitch_domain_models/dummy_connector","hyperswitch_connectors/dummy_connector"]
external_access_dc = ["dummy_connector"]
detailed_errors = ["api_models/detailed_errors", "error-stack/serde"]
payouts = ["api_models/payouts", "common_enums/payouts", "hyperswitch_connectors/payouts", "hyperswitch_domain_models/payouts", "storage_impl/payouts", "payment_methods/payouts"]
payout_retry = ["payouts"]
recon = ["email", "api_models/recon"]

View File

@@ -866,8 +866,6 @@ impl ErrorSwitch<StripeErrorCode> for errors::ApiErrorResponse {
}
}
impl crate::services::EmbedError for error_stack::Report<StripeErrorCode> {}
impl ErrorSwitch<StripeErrorCode> for CustomersErrorResponse {
fn switch(&self) -> StripeErrorCode {
use StripeErrorCode as SC;

View File

@@ -32,7 +32,6 @@ where
Q: Serialize + std::fmt::Debug + 'a + ApiEventMetric,
S: TryFrom<Q> + Serialize,
E: Serialize + error_stack::Context + actix_web::ResponseError + Clone,
error_stack::Report<E>: services::EmbedError,
errors::ApiErrorResponse: ErrorSwitch<E>,
T: std::fmt::Debug + Serialize + ApiEventMetric,
{

View File

@@ -260,46 +260,6 @@ pub enum GooglePayDecryptionError {
ParsingFailed,
}
#[cfg(feature = "detailed_errors")]
pub mod error_stack_parsing {
#[derive(serde::Deserialize)]
pub struct NestedErrorStack<'a> {
context: std::borrow::Cow<'a, str>,
attachments: Vec<std::borrow::Cow<'a, str>>,
sources: Vec<NestedErrorStack<'a>>,
}
#[derive(serde::Serialize, Debug)]
struct LinearErrorStack<'a> {
context: std::borrow::Cow<'a, str>,
#[serde(skip_serializing_if = "Vec::is_empty")]
attachments: Vec<std::borrow::Cow<'a, str>>,
}
#[derive(serde::Serialize, Debug)]
pub struct VecLinearErrorStack<'a>(Vec<LinearErrorStack<'a>>);
impl<'a> From<Vec<NestedErrorStack<'a>>> for VecLinearErrorStack<'a> {
fn from(value: Vec<NestedErrorStack<'a>>) -> Self {
let multi_layered_errors: Vec<_> = value
.into_iter()
.flat_map(|current_error| {
[LinearErrorStack {
context: current_error.context,
attachments: current_error.attachments,
}]
.into_iter()
.chain(Into::<VecLinearErrorStack<'a>>::into(current_error.sources).0)
})
.collect();
Self(multi_layered_errors)
}
}
}
#[cfg(feature = "detailed_errors")]
pub use error_stack_parsing::*;
#[derive(Debug, Clone, thiserror::Error)]
pub enum RoutingError {
#[error("Merchant routing algorithm not found in cache")]

View File

@@ -1116,7 +1116,7 @@ pub type IfCondition = Vec<Comparison>;
pub struct IfStatement {
// #[schema(value_type=Vec<Comparison>)]
pub condition: IfCondition,
pub nested: Option<Vec<IfStatement>>,
pub nested: Option<Vec<Self>>,
}
/// Represents a rule

View File

@@ -568,50 +568,9 @@ where
pub fn log_and_return_error_response<T>(error: Report<T>) -> HttpResponse
where
T: error_stack::Context + Clone + ResponseError,
Report<T>: EmbedError,
{
logger::error!(?error);
HttpResponse::from_error(error.embed().current_context().clone())
}
pub trait EmbedError: Sized {
fn embed(self) -> Self {
self
}
}
impl EmbedError for Report<api_models::errors::types::ApiErrorResponse> {
fn embed(self) -> Self {
#[cfg(feature = "detailed_errors")]
{
let mut report = self;
let error_trace = serde_json::to_value(&report).ok().and_then(|inner| {
serde_json::from_value::<Vec<errors::NestedErrorStack<'_>>>(inner)
.ok()
.map(Into::<errors::VecLinearErrorStack<'_>>::into)
.map(serde_json::to_value)
.transpose()
.ok()
.flatten()
});
match report.downcast_mut::<api_models::errors::types::ApiErrorResponse>() {
None => {}
Some(inner) => {
inner.get_internal_error_mut().stacktrace = error_trace;
}
}
report
}
#[cfg(not(feature = "detailed_errors"))]
self
}
}
impl EmbedError
for Report<hyperswitch_domain_models::errors::api_error_response::ApiErrorResponse>
{
HttpResponse::from_error(error.current_context().clone())
}
pub fn http_response_json<T: body::MessageBody + 'static>(response: T) -> HttpResponse {

View File

@@ -152,6 +152,8 @@ fn implement_error_message(
}
quote! {
// Some fields of enum variants may not be used in the message
#[allow(unused_variables, unused_assignments)]
pub fn error_message(&self) -> String {
match self {
#(#arms),*

View File

@@ -6,7 +6,7 @@ pub use redis_interface::errors::RedisError;
pub use storage_impl::errors::ApplicationError;
use storage_impl::errors::{RecoveryError, StorageError};
use crate::env::logger::{self, error};
use crate::env::logger;
#[derive(Debug, thiserror::Error)]
pub enum ProcessTrackerError {

View File

@@ -430,8 +430,8 @@ impl<T: DatabaseStore> PaymentAttemptInterface for RouterStore<T> {
use hyperswitch_domain_models::behaviour::Conversion;
let conn = pg_connection_read(self).await?;
let intents = try_join_all(pi.iter().cloned().map(|pi| async {
Conversion::convert(pi)
let intents = try_join_all(pi.iter().map(|pi| async {
Conversion::convert(pi.clone())
.await
.change_context(errors::StorageError::EncryptionError)
}))

View File

@@ -7,7 +7,7 @@ use std::{
};
use anyhow::{Context, Result};
use clap::{arg, command, Parser, ValueEnum};
use clap::{Parser, ValueEnum};
use masking::PeekInterface;
use regex::Regex;

View File

@@ -16,8 +16,8 @@ use thirtyfour::{components::SelectElement, prelude::*, WebDriver};
#[derive(Clone)]
pub enum Event<'a> {
RunIf(Assert<'a>, Vec<Event<'a>>),
EitherOr(Assert<'a>, Vec<Event<'a>>, Vec<Event<'a>>),
RunIf(Assert<'a>, Vec<Self>),
EitherOr(Assert<'a>, Vec<Self>, Vec<Self>),
Assert(Assert<'a>),
Trigger(Trigger<'a>),
}