diff options
| author | Manish Goregaokar <manishsmail@gmail.com> | 2016-10-04 15:24:03 +0530 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-10-04 15:24:03 +0530 |
| commit | 5c55db9450f6e06ae8c40735d112804b260ac62c (patch) | |
| tree | 9bdb536ede50d009cf453cf2064fd373d347afaa /src/libsyntax/parse | |
| parent | ad7635894ff699d2f5363eac80c70e491e3c17c4 (diff) | |
| parent | 9e3dcb45493366c790d333aaf4dfa5a043e49a63 (diff) | |
| download | rust-5c55db9450f6e06ae8c40735d112804b260ac62c.tar.gz rust-5c55db9450f6e06ae8c40735d112804b260ac62c.zip | |
Rollup merge of #36921 - nnethercote:two-lexer-tweaks, r=nrc
Two lexer tweaks 19 days later, I haven't received a review of my commits in #36470. In an attempt to make some progress, I'm going to split up the changes. Here are the ones that don't relate to renaming things.
Diffstat (limited to 'src/libsyntax/parse')
| -rw-r--r-- | src/libsyntax/parse/lexer/mod.rs | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/src/libsyntax/parse/lexer/mod.rs b/src/libsyntax/parse/lexer/mod.rs index 6c0e2425d37..0ba2db3310c 100644 --- a/src/libsyntax/parse/lexer/mod.rs +++ b/src/libsyntax/parse/lexer/mod.rs @@ -417,11 +417,9 @@ impl<'a> StringReader<'a> { self.last_pos = self.pos; let current_byte_offset = self.byte_offset(self.pos).to_usize(); if current_byte_offset < self.source_text.len() { - assert!(self.curr.is_some()); let last_char = self.curr.unwrap(); let ch = char_at(&self.source_text, current_byte_offset); - let next = current_byte_offset + ch.len_utf8(); - let byte_offset_diff = next - current_byte_offset; + let byte_offset_diff = ch.len_utf8(); self.pos = self.pos + Pos::from_usize(byte_offset_diff); self.curr = Some(ch); self.col = self.col + CharPos(1); @@ -509,11 +507,7 @@ impl<'a> StringReader<'a> { // line comments starting with "///" or "//!" are doc-comments let doc_comment = self.curr_is('/') || self.curr_is('!'); - let start_bpos = if doc_comment { - self.pos - BytePos(3) - } else { - self.last_pos - BytePos(2) - }; + let start_bpos = self.last_pos - BytePos(2); while !self.is_eof() { match self.curr.unwrap() { |
