about summary refs log tree commit diff
path: root/compiler/rustc_session/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2022-12-06 09:21:49 +0000
committerbors <bors@rust-lang.org>2022-12-06 09:21:49 +0000
commit9db224fc908059986c179fc6ec433944e9cfce50 (patch)
tree1d7ea6499772331aeb35a1b4cebb1c7e18c46d19 /compiler/rustc_session/src
parentc5351ad4dcd9f3d73241b2acbfc6b4631da845c5 (diff)
parent56aacb245ce484994ac2e0ecab72b477ad6dc362 (diff)
downloadrust-9db224fc908059986c179fc6ec433944e9cfce50.tar.gz
rust-9db224fc908059986c179fc6ec433944e9cfce50.zip
Auto merge of #105175 - michaelwoerister:add-stable-ord-trait, r=nagisa
Add StableOrd trait as proposed in MCP 533.

The `StableOrd` trait can be used to mark types as having a stable sort order across compilation sessions. Collections that sort their items in a stable way can safely implement HashStable by hashing items in sort order.

See https://github.com/rust-lang/compiler-team/issues/533 for more information.
Diffstat (limited to 'compiler/rustc_session/src')
-rw-r--r--compiler/rustc_session/src/config.rs5
1 files changed, 4 insertions, 1 deletions
diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs
index d8c4b0845d0..7a20100fd31 100644
--- a/compiler/rustc_session/src/config.rs
+++ b/compiler/rustc_session/src/config.rs
@@ -10,7 +10,7 @@ use crate::{lint, HashStableContext};
 
 use rustc_data_structures::fx::{FxHashMap, FxHashSet};
 
-use rustc_data_structures::stable_hasher::ToStableHashKey;
+use rustc_data_structures::stable_hasher::{StableOrd, ToStableHashKey};
 use rustc_target::abi::Align;
 use rustc_target::spec::{PanicStrategy, SanitizerSet, SplitDebuginfo};
 use rustc_target::spec::{Target, TargetTriple, TargetWarnings, TARGETS};
@@ -288,6 +288,9 @@ pub enum OutputType {
     DepInfo,
 }
 
+// Safety: Trivial C-Style enums have a stable sort order across compilation sessions.
+unsafe impl StableOrd for OutputType {}
+
 impl<HCX: HashStableContext> ToStableHashKey<HCX> for OutputType {
     type KeyType = Self;