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_session/src/config.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'compiler/rustc_session/src') diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs index d5428df0329..f4fd9dee02e 100644 --- a/compiler/rustc_session/src/config.rs +++ b/compiler/rustc_session/src/config.rs @@ -491,9 +491,11 @@ pub enum OutputType { DepInfo, } -// Trivial C-Style enums have a stable sort order across compilation sessions. impl StableOrd for OutputType { const CAN_USE_UNSTABLE_SORT: bool = true; + + // Trivial C-Style enums have a stable sort order across compilation sessions. + const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: () = (); } impl ToStableHashKey for OutputType { -- cgit 1.4.1-3-g733a5