🦀 An Incoherent Rust
Source: boxyuwu.blog | Hacker News
Tags: Rust Programming Languages Ecosystem Compiler
The Core Problem
Foundational crates like serde define traits that every other crate needs to implement for their types. If a crate doesn't implement Serialize, downstream crates can't use it with serde. And if someone publishes an alternative (e.g., nextserde), all crates that support serde also need to add support for the new library—a unrealistic amount of work.
Why Orphan Rules Exist
1. The HashMap Problem
Without orphan rules, different crates could implement Hash for the same type in conflicting ways. When you pass a HashSet from crate B to crate C, the Hash impl used to construct it might differ from the Hash impl used to check it—leading to nonsensical results.
2. Soundness
Coherence is necessary for type system soundness. Overlapping trait impls with different associated types could allow safe code to transmute between types (e.g., *const u8 → Box<u8>).
Existing Proposals
- Binary Crate Exemption: Remove orphan rules for binaries (but harms library evolution)
- Deferred Coherence: Check at link time (but unsound with dynamic linking)
- Coherence Domains: Allow cargo workspaces to be treated as one unit
- Fundamental Trait Marker: Mark traits as "fundamental" to opt out of orphan rules
Why This Matters
There's a strong incentive for "got there first" crates to stick around regardless of whether better alternatives exist—simply because it's artificially difficult to replace them. This is not the fault of any library author, but forced onto the ecosystem by the language itself.
"Even though there are no overlapping impls this code is still rejected due to the orphan rules."
Explored from Hacker News (news.ycombinator.com) | 2026-03-24