From 0e73e7095ae7aa7ead69c4ba7ba002560ef118fa Mon Sep 17 00:00:00 2001 From: Alan Egerton Date: Sat, 22 Jun 2024 07:11:42 +0100 Subject: 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. --- compiler/rustc_query_system/src/dep_graph/dep_node.rs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'compiler/rustc_query_system') diff --git a/compiler/rustc_query_system/src/dep_graph/dep_node.rs b/compiler/rustc_query_system/src/dep_graph/dep_node.rs index 3fb59ad26f6..f2a68e35671 100644 --- a/compiler/rustc_query_system/src/dep_graph/dep_node.rs +++ b/compiler/rustc_query_system/src/dep_graph/dep_node.rs @@ -304,6 +304,9 @@ impl ToStableHashKey for WorkProductId { impl StableOrd for WorkProductId { // Fingerprint can use unstable (just a tuple of `u64`s), so WorkProductId can as well const CAN_USE_UNSTABLE_SORT: bool = true; + + // `WorkProductId` sort order is not affected by (de)serialization. + const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: () = (); } // Some types are used a lot. Make sure they don't unintentionally get bigger. -- cgit 1.4.1-3-g733a5