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.
This commit is contained in:
parent
11663b1b48
commit
3a58309798
7 changed files with 96 additions and 36 deletions
|
@ -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;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue