diff --git a/CHANGELOG.md b/CHANGELOG.md index a21bf9e..39651ac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,13 @@ All notable changes to this project will be documented in this file. ## [Unreleased] +## [0.21.1] - 2025-10-09 + +### Fixed +- Packed rarely used `AppError` context (source and backtrace slots) inside the + boxed inner payload so the `AppResult` alias no longer triggers Clippy's + `result_large_err` lint under `-D warnings`. + ## [0.21.0] - 2025-10-08 ### Added diff --git a/Cargo.lock b/Cargo.lock index b71bd79..8e6eb42 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1727,7 +1727,7 @@ dependencies = [ [[package]] name = "masterror" -version = "0.21.0" +version = "0.21.1" dependencies = [ "actix-web", "axum 0.8.4", diff --git a/Cargo.toml b/Cargo.toml index ffeffb4..27f3748 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "masterror" -version = "0.21.0" +version = "0.21.1" rust-version = "1.90" edition = "2024" license = "MIT OR Apache-2.0" diff --git a/README.md b/README.md index 57a881b..17c08b6 100644 --- a/README.md +++ b/README.md @@ -73,9 +73,9 @@ The build script keeps the full feature snippet below in sync with ~~~toml [dependencies] -masterror = { version = "0.21.0", default-features = false } +masterror = { version = "0.21.1", default-features = false } # or with features: -# masterror = { version = "0.21.0", features = [ +# masterror = { version = "0.21.1", features = [ # "axum", "actix", "openapi", "serde_json", # "tracing", "metrics", "backtrace", "sqlx", # "sqlx-migrate", "reqwest", "redis", "validator", diff --git a/README.ru.md b/README.ru.md index a3d5331..a301b06 100644 --- a/README.ru.md +++ b/README.ru.md @@ -67,9 +67,9 @@ MSRV зафиксирован, а родные деривы позволяют ~~~toml [dependencies] -masterror = { version = "0.21.0", default-features = false } +masterror = { version = "0.21.1", default-features = false } # или с нужными фичами: -# masterror = { version = "0.21.0", features = [ +# masterror = { version = "0.21.1", features = [ # "axum", "actix", "openapi", "serde_json", # "tracing", "metrics", "backtrace", "sqlx", # "sqlx-migrate", "reqwest", "redis", "validator", diff --git a/src/app_error/core.rs b/src/app_error/core.rs index cf43ec8..3c791b9 100644 --- a/src/app_error/core.rs +++ b/src/app_error/core.rs @@ -38,20 +38,25 @@ pub enum MessageEditPolicy { #[doc(hidden)] pub struct ErrorInner { /// Stable machine-readable error code. - pub code: AppCode, + pub code: AppCode, /// Semantic error category. - pub kind: AppErrorKind, + pub kind: AppErrorKind, /// Optional, public-friendly message. - pub message: Option>, + pub message: Option>, /// Structured metadata for telemetry. - pub metadata: Metadata, + pub metadata: Metadata, /// Policy describing whether the message can be redacted. - pub edit_policy: MessageEditPolicy, + pub edit_policy: MessageEditPolicy, /// Optional retry advice rendered as `Retry-After`. - pub retry: Option, + pub retry: Option, /// Optional authentication challenge for `WWW-Authenticate`. - pub www_authenticate: Option, - telemetry_dirty: AtomicBool + pub www_authenticate: Option, + pub source: Option>, + #[cfg(feature = "backtrace")] + pub backtrace: Option, + #[cfg(feature = "backtrace")] + pub captured_backtrace: OnceLock>, + telemetry_dirty: AtomicBool } #[cfg(feature = "backtrace")] @@ -156,12 +161,7 @@ mod test_backtrace_override { /// Rich application error preserving domain code, taxonomy and metadata. #[derive(Debug)] pub struct Error { - inner: Box, - source: Option>, - #[cfg(feature = "backtrace")] - backtrace: Option, - #[cfg(feature = "backtrace")] - captured_backtrace: OnceLock> + inner: Box } impl Deref for Error { @@ -228,13 +228,13 @@ impl Error { edit_policy: MessageEditPolicy::Preserve, retry: None, www_authenticate: None, + source: None, + #[cfg(feature = "backtrace")] + backtrace: None, + #[cfg(feature = "backtrace")] + captured_backtrace: OnceLock::new(), telemetry_dirty: AtomicBool::new(true) - }), - source: None, - #[cfg(feature = "backtrace")] - backtrace: None, - #[cfg(feature = "backtrace")] - captured_backtrace: OnceLock::new() + }) } } diff --git a/src/app_error/tests.rs b/src/app_error/tests.rs index 4f21968..592d911 100644 --- a/src/app_error/tests.rs +++ b/src/app_error/tests.rs @@ -548,3 +548,12 @@ fn result_alias_is_generic() { assert!(matches!(default_result, Ok(value) if value == 1)); assert!(matches!(custom_result, Ok(value) if value == 2)); } + +#[test] +fn app_error_fits_result_budget() { + let size = std::mem::size_of::(); + assert!( + size <= 128, + "AppError grew to {size} bytes; keep the Err variant lean" + ); +}