Repository navigation
feat: allow a boxed error in a transparent field [release] - #58
Merged
Merged
Conversation
A type that wraps an error whose concrete type cannot be named, such as the `impl ApiError` a trait method returns, had to write its `ApiError` impl by hand: `#[api_error(transparent)]` needed the field itself to implement `ApiError`, and `Box<dyn ApiError>` cannot. The derive now calls a hidden helper with method syntax, so the compiler dereferences the field until it finds an `ApiError`. This is the approach `thiserror` uses for `Box<dyn Error>` sources. The generated code also names the trait by its full path, so the derive no longer needs `ApiError` to be in scope. Assisted-by: Claude Code (claude-fable-5-2) Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Totodore
marked this pull request as ready for review
November 23, 2026 16:24
Totodore
added a commit
that referenced
this pull request
Nov 23, 2026
The squashed commit of #58 landed without the `[release]` marker, so no release PR was opened for it. This commit carries the marker to trigger one; the diff is comment-only. Assisted-by: Claude Code (claude-fable-5-2) Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
#[api_error(transparent)]needed the field itself to implementApiError, so aBox<dyn ApiError + Send + Sync>field needed a hand-written impl.Box<dyn ApiError>, with or withoutSend/Sync, andBox<ConcreteError>), through a hidden helper called with method syntax.thiserrordoes the same forBox<dyn Error>sources.::api_error::ApiError, so#[derive(api_error::ApiError)]works without importing the trait.thiserrorstill rejects aBox<dyn ApiError>field astransparent,#[source]or#[from]: such a variant uses#[error("{0}")].__privatemodule of the matchingapi-error: both crates must be published together.ApiErrornow names the helper method.ApiErroralready fails ondevelopwith Rust 1.100 locally; this PR does not touch it.🤖 Generated with Claude Code