Auto merge of #122832 - oli-obk:no_ord_def_id3, r=michaelwoerister
Remove `DefId`'s `Partial/Ord` impls work towards https://github.com/rust-lang/rust/issues/90317 based on https://github.com/rust-lang/rust/pull/122824 and https://github.com/rust-lang/rust/pull/122820 r? `@michaelwoerister`
This commit is contained in:
commit
2781687fe5
85 changed files with 451 additions and 533 deletions
|
@ -218,8 +218,6 @@ rustc_index::newtype_index! {
|
|||
///
|
||||
/// You can create a `DefId` from a `LocalDefId` using `local_def_id.to_def_id()`.
|
||||
#[derive(Clone, PartialEq, Eq, Copy)]
|
||||
// Don't derive order on 64-bit big-endian, so we can be consistent regardless of field order.
|
||||
#[cfg_attr(not(all(target_pointer_width = "64", target_endian = "big")), derive(PartialOrd, Ord))]
|
||||
// On below-64 bit systems we can simply use the derived `Hash` impl
|
||||
#[cfg_attr(not(target_pointer_width = "64"), derive(Hash))]
|
||||
#[repr(C)]
|
||||
|
@ -236,6 +234,12 @@ pub struct DefId {
|
|||
pub index: DefIndex,
|
||||
}
|
||||
|
||||
// To ensure correctness of incremental compilation,
|
||||
// `DefId` must not implement `Ord` or `PartialOrd`.
|
||||
// See https://github.com/rust-lang/rust/issues/90317.
|
||||
impl !Ord for DefId {}
|
||||
impl !PartialOrd for DefId {}
|
||||
|
||||
// On 64-bit systems, we can hash the whole `DefId` as one `u64` instead of two `u32`s. This
|
||||
// improves performance without impairing `FxHash` quality. So the below code gets compiled to a
|
||||
// noop on little endian systems because the memory layout of `DefId` is as follows:
|
||||
|
@ -261,22 +265,6 @@ impl Hash for DefId {
|
|||
}
|
||||
}
|
||||
|
||||
// Implement the same comparison as derived with the other field order.
|
||||
#[cfg(all(target_pointer_width = "64", target_endian = "big"))]
|
||||
impl Ord for DefId {
|
||||
#[inline]
|
||||
fn cmp(&self, other: &DefId) -> std::cmp::Ordering {
|
||||
Ord::cmp(&(self.index, self.krate), &(other.index, other.krate))
|
||||
}
|
||||
}
|
||||
#[cfg(all(target_pointer_width = "64", target_endian = "big"))]
|
||||
impl PartialOrd for DefId {
|
||||
#[inline]
|
||||
fn partial_cmp(&self, other: &DefId) -> Option<std::cmp::Ordering> {
|
||||
Some(self.cmp(other))
|
||||
}
|
||||
}
|
||||
|
||||
impl DefId {
|
||||
/// Makes a local `DefId` from the given `DefIndex`.
|
||||
#[inline]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue