Skip to content

Commit e263120

Browse files
committed
Rename StringReader::curr as ch.
Likewise, rename StringReader::curr_is as ch_is. This is a [breaking-change] for libsyntax.
1 parent cb92f5c commit e263120

File tree

2 files changed

+99
-99
lines changed

2 files changed

+99
-99
lines changed

src/libsyntax/parse/lexer/comments.rs

+15-15
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,8 @@ fn push_blank_line_comment(rdr: &StringReader, comments: &mut Vec<Comment>) {
154154
}
155155

156156
fn consume_whitespace_counting_blank_lines(rdr: &mut StringReader, comments: &mut Vec<Comment>) {
157-
while is_pattern_whitespace(rdr.curr) && !rdr.is_eof() {
158-
if rdr.col == CharPos(0) && rdr.curr_is('\n') {
157+
while is_pattern_whitespace(rdr.ch) && !rdr.is_eof() {
158+
if rdr.col == CharPos(0) && rdr.ch_is('\n') {
159159
push_blank_line_comment(rdr, &mut *comments);
160160
}
161161
rdr.bump();
@@ -182,7 +182,7 @@ fn read_line_comments(rdr: &mut StringReader,
182182
debug!(">>> line comments");
183183
let p = rdr.pos;
184184
let mut lines: Vec<String> = Vec::new();
185-
while rdr.curr_is('/') && rdr.nextch_is('/') {
185+
while rdr.ch_is('/') && rdr.nextch_is('/') {
186186
let line = rdr.read_one_line_comment();
187187
debug!("{}", line);
188188
// Doc comments are not put in comments.
@@ -249,9 +249,9 @@ fn read_block_comment(rdr: &mut StringReader,
249249
let mut curr_line = String::from("/*");
250250

251251
// doc-comments are not really comments, they are attributes
252-
if (rdr.curr_is('*') && !rdr.nextch_is('*')) || rdr.curr_is('!') {
253-
while !(rdr.curr_is('*') && rdr.nextch_is('/')) && !rdr.is_eof() {
254-
curr_line.push(rdr.curr.unwrap());
252+
if (rdr.ch_is('*') && !rdr.nextch_is('*')) || rdr.ch_is('!') {
253+
while !(rdr.ch_is('*') && rdr.nextch_is('/')) && !rdr.is_eof() {
254+
curr_line.push(rdr.ch.unwrap());
255255
rdr.bump();
256256
}
257257
if !rdr.is_eof() {
@@ -271,19 +271,19 @@ fn read_block_comment(rdr: &mut StringReader,
271271
if rdr.is_eof() {
272272
panic!(rdr.fatal("unterminated block comment"));
273273
}
274-
if rdr.curr_is('\n') {
274+
if rdr.ch_is('\n') {
275275
trim_whitespace_prefix_and_push_line(&mut lines, curr_line, col);
276276
curr_line = String::new();
277277
rdr.bump();
278278
} else {
279-
curr_line.push(rdr.curr.unwrap());
280-
if rdr.curr_is('/') && rdr.nextch_is('*') {
279+
curr_line.push(rdr.ch.unwrap());
280+
if rdr.ch_is('/') && rdr.nextch_is('*') {
281281
rdr.bump();
282282
rdr.bump();
283283
curr_line.push('*');
284284
level += 1;
285285
} else {
286-
if rdr.curr_is('*') && rdr.nextch_is('/') {
286+
if rdr.ch_is('*') && rdr.nextch_is('/') {
287287
rdr.bump();
288288
rdr.bump();
289289
curr_line.push('/');
@@ -305,7 +305,7 @@ fn read_block_comment(rdr: &mut StringReader,
305305
Isolated
306306
};
307307
rdr.consume_non_eol_whitespace();
308-
if !rdr.is_eof() && !rdr.curr_is('\n') && lines.len() == 1 {
308+
if !rdr.is_eof() && !rdr.ch_is('\n') && lines.len() == 1 {
309309
style = Mixed;
310310
}
311311
debug!("<<< block comment");
@@ -319,11 +319,11 @@ fn read_block_comment(rdr: &mut StringReader,
319319

320320
fn consume_comment(rdr: &mut StringReader, code_to_the_left: bool, comments: &mut Vec<Comment>) {
321321
debug!(">>> consume comment");
322-
if rdr.curr_is('/') && rdr.nextch_is('/') {
322+
if rdr.ch_is('/') && rdr.nextch_is('/') {
323323
read_line_comments(rdr, code_to_the_left, comments);
324-
} else if rdr.curr_is('/') && rdr.nextch_is('*') {
324+
} else if rdr.ch_is('/') && rdr.nextch_is('*') {
325325
read_block_comment(rdr, code_to_the_left, comments);
326-
} else if rdr.curr_is('#') && rdr.nextch_is('!') {
326+
} else if rdr.ch_is('#') && rdr.nextch_is('!') {
327327
read_shebang_comment(rdr, code_to_the_left, comments);
328328
} else {
329329
panic!();
@@ -357,7 +357,7 @@ pub fn gather_comments_and_literals(span_diagnostic: &errors::Handler,
357357
loop {
358358
let mut code_to_the_left = !first_read;
359359
rdr.consume_non_eol_whitespace();
360-
if rdr.curr_is('\n') {
360+
if rdr.ch_is('\n') {
361361
code_to_the_left = false;
362362
consume_whitespace_counting_blank_lines(&mut rdr, &mut comments);
363363
}

0 commit comments

Comments
 (0)