about summary refs log tree commit diff
path: root/compiler/rustc_span
diff options
context:
space:
mode:
authorAlan Egerton <eggyal@gmail.com>2024-06-22 07:11:42 +0100
committerAlan Egerton <eggyal@gmail.com>2024-06-22 07:17:02 +0100
commit0e73e7095ae7aa7ead69c4ba7ba002560ef118fa (patch)
tree53404cdeb87fe3cc5dee1ebc7688c5c1947017fa /compiler/rustc_span
parent114dd2061e0bfa6bc1353d0265389cfaa04d8858 (diff)
downloadrust-0e73e7095ae7aa7ead69c4ba7ba002560ef118fa.tar.gz
rust-0e73e7095ae7aa7ead69c4ba7ba002560ef118fa.zip
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.
Diffstat (limited to 'compiler/rustc_span')
-rw-r--r--compiler/rustc_span/src/def_id.rs4
1 files changed, 3 insertions, 1 deletions
diff --git a/compiler/rustc_span/src/def_id.rs b/compiler/rustc_span/src/def_id.rs
index 4d534ad8007..5456303b36f 100644
--- a/compiler/rustc_span/src/def_id.rs
+++ b/compiler/rustc_span/src/def_id.rs
@@ -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