about summary refs log tree commit diff
path: root/compiler/rustc_span/src
diff options
context:
space:
mode:
authorlong-long-float <niinikazuki@yahoo.co.jp>2024-02-09 01:03:38 +0900
committerlong-long-float <niinikazuki@yahoo.co.jp>2024-02-09 01:03:38 +0900
commit4e7941c2c57441d2fe92a21c2951cab2926f5656 (patch)
tree079d4b87a8f9475faa847006688ac135c0523548 /compiler/rustc_span/src
parent8cc50849500b2208a0c8faf39c31425267ecb941 (diff)
Check with overlaps_or_adjacent
Diffstat (limited to 'compiler/rustc_span/src')
-rw-r--r--compiler/rustc_span/src/lib.rs7
1 files changed, 7 insertions, 0 deletions
diff --git a/compiler/rustc_span/src/lib.rs b/compiler/rustc_span/src/lib.rs
index ea6766ea583..228d33bdba2 100644
--- a/compiler/rustc_span/src/lib.rs
+++ b/compiler/rustc_span/src/lib.rs
@@ -627,6 +627,13 @@ impl Span {
         span.lo < other.hi && other.lo < span.hi
     }
 
+    /// Returns `true` if `self` touches or adjoins `other`.
+    pub fn overlaps_or_adjacent(self, other: Span) -> bool {
+        let span = self.data();
+        let other = other.data();
+        span.lo <= other.hi && other.lo <= span.hi
+    }
+
     /// Returns `true` if the spans are equal with regards to the source text.
     ///
     /// Use this instead of `==` when either span could be generated code,