Skip to content

Commit 1bb85bd

Browse files
chore: add utility function for relative span positions
1 parent 5696e38 commit 1bb85bd

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/parse/session.rs

+9
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,15 @@ impl ParseSess {
218218
self.parse_sess.source_map().lookup_char_pos(pos).line
219219
}
220220

221+
// TODO(calebcartwright): Preemptive, currently unused addition
222+
// that will be used to support formatting scenarios that take original
223+
// positions into account
224+
/// Determines whether two byte positions are in the same source line.
225+
#[allow(dead_code)]
226+
pub(crate) fn byte_pos_same_line(&self, a: BytePos, b: BytePos) -> bool {
227+
self.line_of_byte_pos(a) == self.line_of_byte_pos(b)
228+
}
229+
221230
pub(crate) fn span_to_debug_info(&self, span: Span) -> String {
222231
self.parse_sess.source_map().span_to_diagnostic_string(span)
223232
}

0 commit comments

Comments
 (0)