From 4e7941c2c57441d2fe92a21c2951cab2926f5656 Mon Sep 17 00:00:00 2001 From: long-long-float Date: Fri, 9 Feb 2024 01:03:38 +0900 Subject: Check with overlaps_or_adjacent --- compiler/rustc_span/src/lib.rs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'compiler/rustc_span/src') 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, -- cgit 1.4.1-3-g733a5