From 1bb85bdf6b6dc0e205009b9f531a6220fe2031f9 Mon Sep 17 00:00:00 2001 From: Caleb Cartwright Date: Wed, 9 Mar 2022 20:53:51 -0600 Subject: [PATCH] chore: add utility function for relative span positions --- src/parse/session.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/parse/session.rs b/src/parse/session.rs index 87ab8fbf20a..a95324bbb0e 100644 --- a/src/parse/session.rs +++ b/src/parse/session.rs @@ -218,6 +218,15 @@ impl ParseSess { self.parse_sess.source_map().lookup_char_pos(pos).line } + // TODO(calebcartwright): Preemptive, currently unused addition + // that will be used to support formatting scenarios that take original + // positions into account + /// Determines whether two byte positions are in the same source line. + #[allow(dead_code)] + pub(crate) fn byte_pos_same_line(&self, a: BytePos, b: BytePos) -> bool { + self.line_of_byte_pos(a) == self.line_of_byte_pos(b) + } + pub(crate) fn span_to_debug_info(&self, span: Span) -> String { self.parse_sess.source_map().span_to_diagnostic_string(span) }