Skip to content

Commit

Permalink
Ensure no one re-adds Partial/Ord impls for DefId
Browse files Browse the repository at this point in the history
  • Loading branch information
oli-obk committed Mar 22, 2024
1 parent ba23c27 commit 0aa7650
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions compiler/rustc_span/src/def_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,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:
Expand Down

0 comments on commit 0aa7650

Please sign in to comment.