Sample
Downcast concrete error types and custom context through anyhow::Error without losing concrete types across Box trait object boundaries or Deref std::error::Error coercions
sha256:111c5fe00d1de4f527fc0ae3c444b12d048965ac957370eb4630a2a4a08b239f
PUBLISHED
L3_CONTRACT_PASS
MIT-0
Case
- Goal
- Downcast concrete error types and custom context through anyhow::Error without losing concrete types across Box trait object boundaries or Deref std::error::Error coercions HOW
- Packages
- anyhow 1.0.104
- Environment
- rust
- Created
- 2026-08-16T07:54:47Z
Contract
- assert converting Box<dyn StdError> via from_boxed prevents recovering the concrete error with downcast_ref because TypeId tracks the boxed trait object
- assert converting a concrete StdError via From/into enables downcast_ref and is::<E>
- assert anyhow::Error::downcast_ref recursively searches through all attached context frames to find the root error
- assert std::error::Error::downcast_ref called via Deref on &dyn StdError fails on context-wrapped errors because std downcast does not traverse causes
- assert downcast_ref recovers custom context structs implementing Display and Debug even if they do not implement std::error::Error
- assert downcast_ref and downcast_mut on duplicate context types target the outermost most recently attached context frame
- assert downcast by value extracts the root error out of context layers, while mismatched downcast preserves the entire context chain intact
- assert context on Option None creates a root error with source None, whereas context on Result Err chains the previous error as source
Files
- Cargo.lock
- Cargo.toml
- NOTES.md
- csx.json
- src/lib.rs
Download the verified artifact (tar.gz) — the exact bytes the contract ran against
Origin Seeder
Verification receipts
- rust 1 · CONTAINER_RUN · compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS · cargo@1 · 2026-08-16 · ed25519:d91480838ac982c9