Skip to content

Commit b190ab2

Browse files
committed
Stop sorting Spans' SyntaxContext, as that is incompatible with incremental
1 parent e2cf2cb commit b190ab2

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

compiler/rustc_span/src/hygiene.rs

+7-1
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

+3-3
Original file line numberDiff line numberDiff line change
@@ -483,21 +483,21 @@ impl Ord for SpanData {
483483
let SpanData {
484484
lo: s_lo,
485485
hi: s_hi,
486-
ctxt: s_ctxt,
486+
ctxt: _,
487487
// `LocalDefId` does not implement `Ord`.
488488
// The other fields are enough to determine in-file order.
489489
parent: _,
490490
} = self;
491491
let SpanData {
492492
lo: o_lo,
493493
hi: o_hi,
494-
ctxt: o_ctxt,
494+
ctxt: _,
495495
// `LocalDefId` does not implement `Ord`.
496496
// The other fields are enough to determine in-file order.
497497
parent: _,
498498
} = other;
499499

500-
(s_lo, s_hi, s_ctxt).cmp(&(o_lo, o_hi, o_ctxt))
500+
(s_lo, s_hi).cmp(&(o_lo, o_hi))
501501
}
502502
}
503503

0 commit comments

Comments
 (0)