Skip to content

Commit

Permalink
improve wording
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed Sep 4, 2023
1 parent efa6f1e commit 8aebbc1
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions library/core/src/cmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,15 @@ use self::Ordering::*;
/// Note that the `B: PartialEq<A>` (symmetric) and `A: PartialEq<C>`
/// (transitive) impls are not forced to exist, but these requirements apply
/// whenever they do exist.
/// The requirement for transitive chains has a subtle consequence: if a crate `a` with type `A`
/// importing types `B1`, `B2` from another crate `b` defines instances of both `A: PartialEq<B1>`
/// and `B2: PartialEq<A>`, then if `b` adds a `B1: PartialEq<B2>` implementation in the future that
/// could create new violations of transitivity. Effectively, crate `a` is making `B1` and `B2`
/// comparable even though `b` does not permit comparing them. Crate `a` should generally refrain
/// from doing that to avoid the potential for such conflicts.
/// The requirement for transitive chains has a subtle consequence: consider a crate `alpha`
/// defining type `A1` and `A2`, and a crate `beta` defining a type `B`. If `beta` uses `alpha` as a
/// dependency and provides trait implementations for both `A1: PartialEq<B>` and `B:
/// PartialEq<A2>`, the transitivity rules don't apply, as an implementation `A1: PartialEq<A2>`
/// does not exist; but at a later point `alpha` could decide to add such a `A1: PartialEq<A2>`
/// implementation, in a way that would then make `beta`'s traits implementations violate
/// transitivity. Effectively, `beta` is already making `A1` and `A2` comparable for equality even
/// though `alpha` does not permit comparing them. Crate `beta` should generally refrain from doing
/// that to avoid the potential for such conflicts.
///
/// ## Derivable
///
Expand Down

0 comments on commit 8aebbc1

Please sign in to comment.