about summary refs log tree commit diff
path: root/src/libsyntax
diff options
context:
space:
mode:
authorHuon Wilson <dbau.pp+github@gmail.com>2014-02-23 16:40:04 +1100
committerAlex Crichton <alex@alexcrichton.com>2014-02-24 21:22:26 -0800
commitff79a4471cbf5fa4e78fcf56be129a3d56690127 (patch)
tree6835775de94115c4f499981198c8b618330dd2fd /src/libsyntax
parentdad52cfcb58cb30170c6247f2053bc0f0d57466a (diff)
downloadrust-ff79a4471cbf5fa4e78fcf56be129a3d56690127.tar.gz
rust-ff79a4471cbf5fa4e78fcf56be129a3d56690127.zip
syntax: record multibyte chars' positions absolutely, not relative to
file.

Previously multibyte UTF-8 chars were being recorded as byte offsets
from the start of the file, and then later compared against global byte
positions, resulting in the compiler possibly thinking it had a byte
position pointing inside a multibyte character, if there were multibyte
characters in any non-crate files. (Although, sometimes the byte offsets
line up just right to not ICE, but that was a coincidence.)

Fixes #11136.
Fixes #11178.
Diffstat (limited to 'src/libsyntax')
-rw-r--r--src/libsyntax/parse/lexer.rs3
1 files changed, 1 insertions, 2 deletions
diff --git a/src/libsyntax/parse/lexer.rs b/src/libsyntax/parse/lexer.rs
index b711e95bc94..5bace75a5ea 100644
--- a/src/libsyntax/parse/lexer.rs
+++ b/src/libsyntax/parse/lexer.rs
@@ -264,8 +264,7 @@ pub fn bump(rdr: &StringReader) {
         }
 
         if byte_offset_diff > 1 {
-            rdr.filemap.record_multibyte_char(
-                Pos::from_uint(current_byte_offset), byte_offset_diff);
+            rdr.filemap.record_multibyte_char(rdr.last_pos.get(), byte_offset_diff);
         }
     } else {
         rdr.curr.set(None);