From e913d692117e57ea2908461865aa08037f0bd2b9 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Tue, 8 May 2018 19:58:54 +1000 Subject: Remove `StringReader::col`. It only has a single use, within code handling indented block comments. We can replace that with the new `FileMap::col_pos()`, which computes the col position (BytePos instead of CharPos) based on the record of the last newline char (which we already record). This is actually an improvement, because `trim_whitespace_prefix_and_push_line()` was using `col`, which is a `CharPos`, as a slice index, which is a byte/char confusion. --- src/libsyntax_pos/lib.rs | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/libsyntax_pos/lib.rs') diff --git a/src/libsyntax_pos/lib.rs b/src/libsyntax_pos/lib.rs index 2bab958dced..26ab5d0a34b 100644 --- a/src/libsyntax_pos/lib.rs +++ b/src/libsyntax_pos/lib.rs @@ -971,6 +971,15 @@ impl FileMap { lines.push(pos); } + /// Return the BytePos of the beginning of the current line. + pub fn line_begin_pos(&self) -> BytePos { + let lines = self.lines.borrow(); + match lines.last() { + Some(&line_pos) => line_pos, + None => self.start_pos, + } + } + /// Add externally loaded source. /// If the hash of the input doesn't match or no input is supplied via None, /// it is interpreted as an error and the corresponding enum variant is set. -- cgit 1.4.1-3-g733a5