diff --git a/compiler/rustc_span/src/hygiene.rs b/compiler/rustc_span/src/hygiene.rs index 37fea6c122c7a..f9b2f6188886d 100644 --- a/compiler/rustc_span/src/hygiene.rs +++ b/compiler/rustc_span/src/hygiene.rs @@ -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, diff --git a/compiler/rustc_span/src/lib.rs b/compiler/rustc_span/src/lib.rs index 616a7ccc7c64f..eda4558b02a8c 100644 --- a/compiler/rustc_span/src/lib.rs +++ b/compiler/rustc_span/src/lib.rs @@ -460,7 +460,7 @@ 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: _, @@ -468,13 +468,13 @@ impl Ord for SpanData { 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)) } }