1
Fork 0

Ensure careful consideration is given by impls

Added an associated `const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED`
to the `StableOrd` trait to ensure that implementors carefully consider
whether the trait's contract is upheld, as incorrect implementations can
cause miscompilations.
This commit is contained in:
Alan Egerton 2024-06-22 07:11:42 +01:00
parent 114dd2061e
commit 0e73e7095a
No known key found for this signature in database
GPG key ID: 7D4C2F6C22122532
6 changed files with 60 additions and 13 deletions

View file

@ -120,9 +120,11 @@ impl Default for DefPathHash {
}
}
// `DefPathHash` sort order is not affected (de)serialization.
impl StableOrd for DefPathHash {
const CAN_USE_UNSTABLE_SORT: bool = true;
// `DefPathHash` sort order is not affected by (de)serialization.
const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: () = ();
}
/// A [`StableCrateId`] is a 64-bit hash of a crate name, together with all