Skip to content

Commit

Permalink
fix lexing of comments with many \r
Browse files Browse the repository at this point in the history
closes #62863
  • Loading branch information
matklad committed Jul 22, 2019
1 parent 273f42b commit 647bf96
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/libsyntax/parse/lexer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ impl<'a> StringReader<'a> {
loop {
idx = match string[idx..].find('\r') {
None => break,
Some(it) => it + 1
Some(it) => idx + it + 1
};
if string[idx..].chars().next() != Some('\n') {
self.err_span_(start + BytePos(idx as u32 - 1),
Expand Down
10 changes: 10 additions & 0 deletions src/test/ui/parser/several-carriage-returns-in-doc-comment.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Issue #62863
// ignore-tidy-cr

// Note: if you see ^M in this file, that's how your editor renders literal `\r`

/// This doc comment contains three isolated `\r` symbols
//~^ ERROR bare CR not allowed in doc-comment
//~| ERROR bare CR not allowed in doc-comment
//~| ERROR bare CR not allowed in doc-comment
fn main() {}
Expand Down
20 changes: 20 additions & 0 deletions src/test/ui/parser/several-carriage-returns-in-doc-comment.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
error: bare CR not allowed in doc-comment
--> $DIR/several-carriage-returns-in-doc-comment.rs:6:12
|
LL | /// This doc comment contains three isolated `\r` symbols
| ^

error: bare CR not allowed in doc-comment
--> $DIR/several-carriage-returns-in-doc-comment.rs:6:32
|
LL | /// This doc comment contains three isolated `\r` symbols
| ^

error: bare CR not allowed in doc-comment
--> $DIR/several-carriage-returns-in-doc-comment.rs:6:52
|
LL | /// This doc comment contains three isolated `\r` symbols
| ^

error: aborting due to 3 previous errors

Expand Down

0 comments on commit 647bf96

Please sign in to comment.