451#456
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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.
Closes #451
Implements real
AppError::downcastanddowncast_mut(both were stubs that unconditionally failed).Design
StoredSource:Owned(Box<dyn Error + Send + Sync>)/Shared(Arc<...>). Needed because anArc<dyn Error>can never yield exclusive ownership in safe Rust (try_unwraprequiresSized), and the crate forbidsunsafe.downcast::<E>(self) -> Result<Box<E>, Self>: succeeds for an owned immediate source of type E; on failure the error is returned fully intact (box reinserted). Shared sources always return Err — documented with rationale (anyhow does this with unsafe; we don't).downcast_mut::<E>(): owned → mutable box downcast; shared →Arc::get_mut(unique reference only, mirroring anyhow 1.0.103's soundness semantics). No unsafe anywhere.is/downcast_refsemantics unchanged (immediate source);with_sourcenow stores owned,with_source_arcshared — ownership caveats documented;ResultExt::contextsources become downcastable as a bonus.Tests
15 new tests: owned success, wrong-type Err with error intact, shared-Arc Err with strong_count preserved, unique-Arc downcast_mut success, shared-Arc None, mutation visible via downcast_ref, interplay of with_source / with_source_arc / with_context. Stub-era tests replaced. Full suite, doctests (173), no_std build, clippy zero warnings, nightly fmt — all green.