Skip to content

Commit

Permalink
Stop sorting Spans' SyntaxContext, as that is incompatible with i…
Browse files Browse the repository at this point in the history
…ncremental
  • Loading branch information
oli-obk committed Mar 28, 2024
1 parent bd6a96f commit 7bb758b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
8 changes: 7 additions & 1 deletion compiler/rustc_span/src/hygiene.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,15 @@ use std::fmt;
use std::hash::Hash;

/// A `SyntaxContext` represents a chain of pairs `(ExpnId, Transparency)` named "marks".
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[derive(Clone, Copy, PartialEq, Eq, Hash)]
pub struct SyntaxContext(u32);

// To ensure correctness of incremental compilation,
// `SyntaxContext` must not implement `Ord` or `PartialOrd`.
// See https://github.com/rust-lang/rust/issues/90317.
impl !Ord for SyntaxContext {}
impl !PartialOrd for SyntaxContext {}

#[derive(Debug, Encodable, Decodable, Clone)]
pub struct SyntaxContextData {
outer_expn: ExpnId,
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_span/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -460,21 +460,21 @@ impl Ord for SpanData {
let SpanData {
lo: s_lo,
hi: s_hi,
ctxt: s_ctxt,
ctxt: _,
// `LocalDefId` does not implement `Ord`.
// The other fields are enough to determine in-file order.
parent: _,
} = self;
let SpanData {
lo: o_lo,
hi: o_hi,
ctxt: o_ctxt,
ctxt: _,
// `LocalDefId` does not implement `Ord`.
// The other fields are enough to determine in-file order.
parent: _,
} = other;

(s_lo, s_hi, s_ctxt).cmp(&(o_lo, o_hi, o_ctxt))
(s_lo, s_hi).cmp(&(o_lo, o_hi))
}
}

Expand Down

0 comments on commit 7bb758b

Please sign in to comment.