Skip to content

Commit 7bb758b

Browse files
committed
Stop sorting Spans' SyntaxContext, as that is incompatible with incremental
1 parent bd6a96f commit 7bb758b

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

compiler/rustc_span/src/hygiene.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,15 @@ use std::fmt;
4242
use std::hash::Hash;
4343

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

48+
// To ensure correctness of incremental compilation,
49+
// `SyntaxContext` must not implement `Ord` or `PartialOrd`.
50+
// See https://github.com/rust-lang/rust/issues/90317.
51+
impl !Ord for SyntaxContext {}
52+
impl !PartialOrd for SyntaxContext {}
53+
4854
#[derive(Debug, Encodable, Decodable, Clone)]
4955
pub struct SyntaxContextData {
5056
outer_expn: ExpnId,

compiler/rustc_span/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -460,21 +460,21 @@ impl Ord for SpanData {
460460
let SpanData {
461461
lo: s_lo,
462462
hi: s_hi,
463-
ctxt: s_ctxt,
463+
ctxt: _,
464464
// `LocalDefId` does not implement `Ord`.
465465
// The other fields are enough to determine in-file order.
466466
parent: _,
467467
} = self;
468468
let SpanData {
469469
lo: o_lo,
470470
hi: o_hi,
471-
ctxt: o_ctxt,
471+
ctxt: _,
472472
// `LocalDefId` does not implement `Ord`.
473473
// The other fields are enough to determine in-file order.
474474
parent: _,
475475
} = other;
476476

477-
(s_lo, s_hi, s_ctxt).cmp(&(o_lo, o_hi, o_ctxt))
477+
(s_lo, s_hi).cmp(&(o_lo, o_hi))
478478
}
479479
}
480480

0 commit comments

Comments
 (0)