about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDavid Tolnay <dtolnay@gmail.com>2020-05-21 17:05:13 -0700
committerDavid Tolnay <dtolnay@gmail.com>2020-05-21 17:05:36 -0700
commite9fed696b5ae033195e2ec2f9ba1edf2c3dae5c5 (patch)
tree49753878769fe26af119e85e11968fdab7a4eb8f
parent9310e3bd4f425f84fc27878ebf2bda1f30935a63 (diff)
downloadrust-e9fed696b5ae033195e2ec2f9ba1edf2c3dae5c5.tar.gz
rust-e9fed696b5ae033195e2ec2f9ba1edf2c3dae5c5.zip
Impl Ord for proc_macro::LineColumn
-rw-r--r--src/libproc_macro/lib.rs15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/libproc_macro/lib.rs b/src/libproc_macro/lib.rs
index f11401b5a0c..2d5bd7e872b 100644
--- a/src/libproc_macro/lib.rs
+++ b/src/libproc_macro/lib.rs
@@ -39,6 +39,7 @@ mod diagnostic;
 #[unstable(feature = "proc_macro_diagnostic", issue = "54140")]
 pub use diagnostic::{Diagnostic, Level, MultiSpan};
 
+use std::cmp::Ordering;
 use std::ops::{Bound, RangeBounds};
 use std::path::PathBuf;
 use std::str::FromStr;
@@ -420,6 +421,20 @@ impl !Send for LineColumn {}
 #[unstable(feature = "proc_macro_span", issue = "54725")]
 impl !Sync for LineColumn {}
 
+#[unstable(feature = "proc_macro_span", issue = "54725")]
+impl Ord for LineColumn {
+    fn cmp(&self, other: &Self) -> Ordering {
+        self.line.cmp(&other.line).then(self.column.cmp(&other.column))
+    }
+}
+
+#[unstable(feature = "proc_macro_span", issue = "54725")]
+impl PartialOrd for LineColumn {
+    fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
+        Some(self.cmp(other))
+    }
+}
+
 /// The source file of a given `Span`.
 #[unstable(feature = "proc_macro_span", issue = "54725")]
 #[derive(Clone)]