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.
This commit is contained in:
Nicholas Nethercote
2018-05-08 19:58:54 +10:00
parent 444b770f4c
commit e913d69211
3 changed files with 22 additions and 7 deletions

View File

@@ -44,8 +44,6 @@ pub struct StringReader<'a> {
pub next_pos: BytePos,
/// The absolute offset within the codemap of the current character
pub pos: BytePos,
/// The column of the next character to read
pub col: CharPos,
/// The current character (which has been read from self.pos)
pub ch: Option<char>,
pub filemap: Lrc<syntax_pos::FileMap>,
@@ -175,7 +173,6 @@ impl<'a> StringReader<'a> {
sess,
next_pos: filemap.start_pos,
pos: filemap.start_pos,
col: CharPos(0),
ch: Some('\n'),
filemap,
end_src_index: src.len(),
@@ -442,9 +439,6 @@ impl<'a> StringReader<'a> {
if self.save_new_lines_and_multibyte {
self.filemap.next_line(self.next_pos);
}
self.col = CharPos(0);
} else {
self.col = self.col + CharPos(1);
}
if next_ch_len > 1 {
if self.save_new_lines_and_multibyte {