Skip to content

Commit e9fed69

Browse files
committed
Impl Ord for proc_macro::LineColumn
1 parent 9310e3b commit e9fed69

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/libproc_macro/lib.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ mod diagnostic;
3939
#[unstable(feature = "proc_macro_diagnostic", issue = "54140")]
4040
pub use diagnostic::{Diagnostic, Level, MultiSpan};
4141

42+
use std::cmp::Ordering;
4243
use std::ops::{Bound, RangeBounds};
4344
use std::path::PathBuf;
4445
use std::str::FromStr;
@@ -420,6 +421,20 @@ impl !Send for LineColumn {}
420421
#[unstable(feature = "proc_macro_span", issue = "54725")]
421422
impl !Sync for LineColumn {}
422423

424+
#[unstable(feature = "proc_macro_span", issue = "54725")]
425+
impl Ord for LineColumn {
426+
fn cmp(&self, other: &Self) -> Ordering {
427+
self.line.cmp(&other.line).then(self.column.cmp(&other.column))
428+
}
429+
}
430+
431+
#[unstable(feature = "proc_macro_span", issue = "54725")]
432+
impl PartialOrd for LineColumn {
433+
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
434+
Some(self.cmp(other))
435+
}
436+
}
437+
423438
/// The source file of a given `Span`.
424439
#[unstable(feature = "proc_macro_span", issue = "54725")]
425440
#[derive(Clone)]

0 commit comments

Comments
 (0)