is there a single document describing rust's coherence rules? googling gives various blog posts and RFCs but I'm struggling to find a single definition of this
-
Show this thread
-
but would I be wrong in saying that "coherence" is the set of rules that means rustc can determine a single `fn` to dispatch to, for every method/function call site, without ambiguity?
2 replies 0 retweets 0 likesShow this thread -
and it's what necessitates things like the orphan rules, `fundamental`, the "conflicting implementation" error for blanket impls for different traits...
1 reply 0 retweets 0 likesShow this thread -
further to this, what's the best explanation of `fundamental` in existence? I'm trying to explain why you can't have an impl for `&mut T` if you also have one for `F where F: FnMut(T)`, but you can have one for `&mut i64` because that type will never impl FnMut
1 reply 0 retweets 0 likesShow this thread -
Replying to @mountain_ghosts
Rust prevents you from negative reasoning on foreign traits/types for forwards compatibility. A few types/traits are allowed to break this rule for ergonomic reasons, the trade-off being that implementing a trait for a fundamental type is a breaking change.
3 replies 0 retweets 0 likes -
Replying to @sgrif
yeah I'm starting to get the intersection of this problem and logic programming and why so much of the material on this topic is "we can't do negative reasoning"
1 reply 0 retweets 0 likes -
Replying to @mountain_ghosts
The rebalancing coherence rfc lays out the reasoning pretty clearly. If we let you rely on ForeignType: !ForeignTrait, implementing any trait for any type would be a breaking change. So there's a balance chosen between permitting as much as possible while allowing lib evolution
2 replies 0 retweets 0 likes
In fact the error message you get in these cases should even way something like "foreign_crate may implement ForeignTrait for ForeignType in a future version"
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.