Skip to content

Commit aef0581

Browse files
committed
Fix byte offset and error message inconsistencies
1 parent a76244f commit aef0581

File tree

1 file changed

+3
-3
lines changed
  • src/libsyntax/parse/lexer

1 file changed

+3
-3
lines changed

src/libsyntax/parse/lexer/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ impl<'a> StringReader<'a> {
406406

407407
// line comments starting with "///" or "//!" are doc-comments
408408
let doc_comment = self.curr_is('/') || self.curr_is('!');
409-
let start_bpos = self.pos - BytePos(3);
409+
let start_bpos = self.last_pos - BytePos(2);
410410

411411
while !self.is_eof() {
412412
match self.curr.unwrap() {
@@ -415,9 +415,9 @@ impl<'a> StringReader<'a> {
415415
if self.nextch_is('\n') {
416416
// CRLF
417417
break
418-
} else {
418+
} else if doc_comment {
419419
self.err_span_(self.last_pos, self.pos,
420-
"bare CR not allowed in comment");
420+
"bare CR not allowed in doc-comment");
421421
}
422422
}
423423
_ => ()

0 commit comments

Comments
 (0)