Skip to content

Commit 94565a4

Browse files
committed
Rename StringReader::pos as next_pos.
This is a [breaking-change] for libsyntax.
1 parent 3c4c859 commit 94565a4

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

src/libsyntax/parse/lexer/mod.rs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ pub struct TokenAndSpan {
7777
pub struct StringReader<'a> {
7878
pub span_diagnostic: &'a Handler,
7979
/// The absolute offset within the codemap of the next character to read
80-
pub pos: BytePos,
80+
pub next_pos: BytePos,
8181
/// The absolute offset within the codemap of the last character read(curr)
8282
pub last_pos: BytePos,
8383
/// The column of the next character to read
@@ -107,7 +107,7 @@ impl<'a> Reader for StringReader<'a> {
107107
}
108108

109109
match self.terminator {
110-
Some(t) => self.pos > t,
110+
Some(t) => self.next_pos > t,
111111
None => false,
112112
}
113113
}
@@ -173,7 +173,7 @@ impl<'a> Reader for TtReader<'a> {
173173
}
174174

175175
impl<'a> StringReader<'a> {
176-
/// For comments.rs, which hackily pokes into pos and curr
176+
/// For comments.rs, which hackily pokes into next_pos and curr
177177
pub fn new_raw<'b>(span_diagnostic: &'b Handler,
178178
filemap: Rc<syntax_pos::FileMap>)
179179
-> StringReader<'b> {
@@ -195,7 +195,7 @@ impl<'a> StringReader<'a> {
195195

196196
StringReader {
197197
span_diagnostic: span_diagnostic,
198-
pos: filemap.start_pos,
198+
next_pos: filemap.start_pos,
199199
last_pos: filemap.start_pos,
200200
col: CharPos(0),
201201
curr: Some('\n'),
@@ -414,13 +414,13 @@ impl<'a> StringReader<'a> {
414414
/// Advance the StringReader by one character. If a newline is
415415
/// discovered, add it to the FileMap's list of line start offsets.
416416
pub fn bump(&mut self) {
417-
self.last_pos = self.pos;
418-
let current_byte_offset = self.byte_offset(self.pos).to_usize();
417+
self.last_pos = self.next_pos;
418+
let current_byte_offset = self.byte_offset(self.next_pos).to_usize();
419419
if current_byte_offset < self.source_text.len() {
420420
let last_char = self.curr.unwrap();
421421
let ch = char_at(&self.source_text, current_byte_offset);
422422
let byte_offset_diff = ch.len_utf8();
423-
self.pos = self.pos + Pos::from_usize(byte_offset_diff);
423+
self.next_pos = self.next_pos + Pos::from_usize(byte_offset_diff);
424424
self.curr = Some(ch);
425425
self.col = self.col + CharPos(1);
426426
if last_char == '\n' {
@@ -439,7 +439,7 @@ impl<'a> StringReader<'a> {
439439
}
440440

441441
pub fn nextch(&self) -> Option<char> {
442-
let offset = self.byte_offset(self.pos).to_usize();
442+
let offset = self.byte_offset(self.next_pos).to_usize();
443443
if offset < self.source_text.len() {
444444
Some(char_at(&self.source_text, offset))
445445
} else {
@@ -452,7 +452,7 @@ impl<'a> StringReader<'a> {
452452
}
453453

454454
pub fn nextnextch(&self) -> Option<char> {
455-
let offset = self.byte_offset(self.pos).to_usize();
455+
let offset = self.byte_offset(self.next_pos).to_usize();
456456
let s = &self.source_text[..];
457457
if offset >= s.len() {
458458
return None;
@@ -518,7 +518,7 @@ impl<'a> StringReader<'a> {
518518
break;
519519
} else if doc_comment {
520520
self.err_span_(self.last_pos,
521-
self.pos,
521+
self.next_pos,
522522
"bare CR not allowed in doc-comment");
523523
}
524524
}
@@ -695,7 +695,7 @@ impl<'a> StringReader<'a> {
695695
// in range for the true radix
696696
if c.unwrap().to_digit(real_radix).is_none() {
697697
self.err_span_(self.last_pos,
698-
self.pos,
698+
self.next_pos,
699699
&format!("invalid digit for a base {} literal", real_radix));
700700
}
701701
len += 1;
@@ -809,7 +809,7 @@ impl<'a> StringReader<'a> {
809809
accum_int *= 16;
810810
accum_int += c.to_digit(16).unwrap_or_else(|| {
811811
self.err_span_char(self.last_pos,
812-
self.pos,
812+
self.next_pos,
813813
"invalid character in numeric character escape",
814814
c);
815815

@@ -980,11 +980,11 @@ impl<'a> StringReader<'a> {
980980
accum_int += c.to_digit(16).unwrap_or_else(|| {
981981
if c == delim {
982982
panic!(self.fatal_span_(self.last_pos,
983-
self.pos,
983+
self.next_pos,
984984
"unterminated unicode escape (needed a `}`)"));
985985
} else {
986986
self.err_span_char(self.last_pos,
987-
self.pos,
987+
self.next_pos,
988988
"invalid character in unicode escape",
989989
c);
990990
}
@@ -1022,7 +1022,7 @@ impl<'a> StringReader<'a> {
10221022
}
10231023
if self.scan_digits(10, 10) == 0 {
10241024
self.err_span_(self.last_pos,
1025-
self.pos,
1025+
self.next_pos,
10261026
"expected at least one digit in exponent")
10271027
}
10281028
}
@@ -1259,7 +1259,7 @@ impl<'a> StringReader<'a> {
12591259
// if we find one, then this is an invalid character literal
12601260
if self.curr_is('\'') {
12611261
panic!(self.fatal_span_verbose(
1262-
start_with_quote, self.pos,
1262+
start_with_quote, self.next_pos,
12631263
String::from("character literal may only contain one codepoint")));
12641264

12651265
}
@@ -1467,7 +1467,7 @@ impl<'a> StringReader<'a> {
14671467
}
14681468
c => {
14691469
let last_bpos = self.last_pos;
1470-
let bpos = self.pos;
1470+
let bpos = self.next_pos;
14711471
let mut err = self.struct_fatal_span_char(last_bpos,
14721472
bpos,
14731473
"unknown start of token",

src/libsyntax/parse/lexer/unicode_chars.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ pub fn check_for_substitution<'a>(reader: &StringReader<'a>,
234234
.iter()
235235
.find(|&&(c, _, _)| c == ch)
236236
.map(|&(_, u_name, ascii_char)| {
237-
let span = make_span(reader.last_pos, reader.pos);
237+
let span = make_span(reader.last_pos, reader.next_pos);
238238
match ASCII_ARRAY.iter().find(|&&(c, _)| c == ascii_char) {
239239
Some(&(ascii_char, ascii_name)) => {
240240
let msg =

0 commit comments

Comments
 (0)