Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation
Rust adyenbeginner-friendlyfeaturedfinancefintechhacktoberfesthigh-performanceopen-sourceorchestrationpaymentpayment-gatewaypayment-integrationpayment-processingpaymentspayments-platformrestful-apirustsdkstripeworks-with-react
chore: address Rust 1.92.0 clippy lints (#10756)
Sanchith Hegde85f23ecea78e
diff --git a/Cargo.lock b/Cargo.lockindex 99a1266ba1..42e73554ab 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -3124,7 +3124,6 @@ checksum = "27a72baa257b5e0e2de241967bc5ee8f855d6072351042688621081d66b2a76b"dependencies = ["anyhow","rustc_version 0.4.1",- "serde",][[package]]diff --git a/crates/analytics/src/query.rs b/crates/analytics/src/query.rsindex 5b3059cab7..3e4f79254d 100644--- a/crates/analytics/src/query.rs+++ b/crates/analytics/src/query.rs@@ -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 {diff --git a/crates/api_models/Cargo.toml b/crates/api_models/Cargo.tomlindex 3582b8cb88..5c1c426309 100644--- a/crates/api_models/Cargo.toml+++ b/crates/api_models/Cargo.toml@@ -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 = []diff --git a/crates/api_models/src/errors/types.rs b/crates/api_models/src/errors/types.rsindex 1a22a2d5cd..bb6065649a 100644--- a/crates/api_models/src/errors/types.rs+++ b/crates/api_models/src/errors/types.rs@@ -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(),}}}diff --git a/crates/api_models/src/payment_methods.rs b/crates/api_models/src/payment_methods.rsindex b78b6ebdce..886e91adcb 100644--- a/crates/api_models/src/payment_methods.rs+++ b/crates/api_models/src/payment_methods.rs@@ -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;diff --git a/crates/common_utils/src/macros.rs b/crates/common_utils/src/macros.rsindex 27836f236d..59c37daa61 100644--- a/crates/common_utils/src/macros.rs+++ b/crates/common_utils/src/macros.rs@@ -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)]diff --git a/crates/euclid/src/dssa/analyzer.rs b/crates/euclid/src/dssa/analyzer.rsindex 74d7081ad1..20224b4dbe 100644--- a/crates/euclid/src/dssa/analyzer.rs+++ b/crates/euclid/src/dssa/analyzer.rs@@ -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() {diff --git a/crates/euclid/src/dssa/truth.rs b/crates/euclid/src/dssa/truth.rsindex 8724979888..885367559c 100644--- a/crates/euclid/src/dssa/truth.rs+++ b/crates/euclid/src/dssa/truth.rs@@ -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(|| {diff --git a/crates/euclid/src/frontend/ast.rs b/crates/euclid/src/frontend/ast.rsindex b887980675..d5935f3f96 100644--- a/crates/euclid/src/frontend/ast.rs+++ b/crates/euclid/src/frontend/ast.rs@@ -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 rulediff --git a/crates/euclid/src/frontend/dir.rs b/crates/euclid/src/frontend/dir.rsindex c870df8e00..7adacc40ff 100644--- a/crates/euclid/src/frontend/dir.rs+++ b/crates/euclid/src/frontend/dir.rs@@ -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)]diff --git a/crates/euclid/src/frontend/vir.rs b/crates/euclid/src/frontend/vir.rsindex 6c8bc7ab2f..abccb7f4a7 100644--- a/crates/euclid/src/frontend/vir.rs+++ b/crates/euclid/src/frontend/vir.rs@@ -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)]diff --git a/crates/hyperswitch_constraint_graph/src/error.rs b/crates/hyperswitch_constraint_graph/src/error.rsindex cd2269de26..64ca3a2ac2 100644--- a/crates/hyperswitch_constraint_graph/src/error.rs+++ b/crates/hyperswitch_constraint_graph/src/error.rs@@ -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>>,},diff --git a/crates/hyperswitch_domain_models/src/payments.rs b/crates/hyperswitch_domain_models/src/payments.rsindex bbf4aeab88..9d3bfdc338 100644--- a/crates/hyperswitch_domain_models/src/payments.rs+++ b/crates/hyperswitch_domain_models/src/payments.rs@@ -1264,9 +1264,7 @@ whereSome(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.diff --git a/crates/router/Cargo.toml b/crates/router/Cargo.tomlindex fb01224513..7e82f906bd 100644--- a/crates/router/Cargo.toml+++ b/crates/router/Cargo.toml@@ -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"]diff --git a/crates/router/src/compatibility/stripe/errors.rs b/crates/router/src/compatibility/stripe/errors.rsindex 6661fb9509..bbdc9fd75b 100644--- a/crates/router/src/compatibility/stripe/errors.rs+++ b/crates/router/src/compatibility/stripe/errors.rs@@ -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;diff --git a/crates/router/src/compatibility/wrap.rs b/crates/router/src/compatibility/wrap.rsindex d00ece8360..cfa7686711 100644--- a/crates/router/src/compatibility/wrap.rs+++ b/crates/router/src/compatibility/wrap.rs@@ -32,7 +32,6 @@ whereQ: 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,{diff --git a/crates/router/src/core/errors.rs b/crates/router/src/core/errors.rsindex a980bb664e..39b52e16ab 100644--- a/crates/router/src/core/errors.rs+++ b/crates/router/src/core/errors.rs@@ -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")]diff --git a/crates/router/src/core/payments/routing/utils.rs b/crates/router/src/core/payments/routing/utils.rsindex c3b7dda97b..4b5ced7c01 100644--- a/crates/router/src/core/payments/routing/utils.rs+++ b/crates/router/src/core/payments/routing/utils.rs@@ -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 rulediff --git a/crates/router/src/services/api.rs b/crates/router/src/services/api.rsindex 8bcb83b4ab..ced9a4f023 100644--- a/crates/router/src/services/api.rs+++ b/crates/router/src/services/api.rs@@ -568,50 +568,9 @@ wherepub fn log_and_return_error_response<T>(error: Report<T>) -> HttpResponsewhereT: 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 {diff --git a/crates/router_derive/src/macros/api_error.rs b/crates/router_derive/src/macros/api_error.rsindex c3a8c1645a..b860de9add 100644--- a/crates/router_derive/src/macros/api_error.rs+++ b/crates/router_derive/src/macros/api_error.rs@@ -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),*diff --git a/crates/scheduler/src/errors.rs b/crates/scheduler/src/errors.rsindex 254c497952..ad79d7a54f 100644--- a/crates/scheduler/src/errors.rs+++ b/crates/scheduler/src/errors.rs@@ -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 {diff --git a/crates/storage_impl/src/payments/payment_attempt.rs b/crates/storage_impl/src/payments/payment_attempt.rsindex 6a3d305f68..da926b5a48 100644--- a/crates/storage_impl/src/payments/payment_attempt.rs+++ b/crates/storage_impl/src/payments/payment_attempt.rs@@ -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)}))diff --git a/crates/test_utils/src/newman_runner.rs b/crates/test_utils/src/newman_runner.rsindex 096dec8254..d5d5df7be4 100644--- a/crates/test_utils/src/newman_runner.rs+++ b/crates/test_utils/src/newman_runner.rs@@ -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;diff --git a/crates/test_utils/tests/connectors/selenium.rs b/crates/test_utils/tests/connectors/selenium.rsindex c7d0c20981..65df280813 100644--- a/crates/test_utils/tests/connectors/selenium.rs+++ b/crates/test_utils/tests/connectors/selenium.rs@@ -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>),}