Skip to content

Commit 57ee03f

Browse files
committed
Implement Ord,PartialOrd for SpanData
1 parent 914459a commit 57ee03f

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

compiler/rustc_span/src/lib.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ impl FileName {
430430
/// `SpanData` is public because `Span` uses a thread-local interner and can't be
431431
/// sent to other threads, but some pieces of performance infra run in a separate thread.
432432
/// Using `Span` is generally preferred.
433-
#[derive(Clone, Copy, Hash, PartialEq, Eq, Ord, PartialOrd)]
433+
#[derive(Clone, Copy, Hash, PartialEq, Eq)]
434434
pub struct SpanData {
435435
pub lo: BytePos,
436436
pub hi: BytePos,
@@ -440,6 +440,18 @@ pub struct SpanData {
440440
pub parent: Option<LocalDefId>,
441441
}
442442

443+
impl Ord for SpanData {
444+
fn cmp(&self, other: &Self) -> Ordering {
445+
(self.lo, self.hi, self.ctxt).cmp(&(other.lo, other.hi, other.ctxt))
446+
}
447+
}
448+
449+
impl PartialOrd for SpanData {
450+
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
451+
Some((self.lo, self.hi, self.ctxt).cmp(&(other.lo, other.hi, other.ctxt)))
452+
}
453+
}
454+
443455
impl SpanData {
444456
#[inline]
445457
pub fn span(&self) -> Span {

0 commit comments

Comments
 (0)