Rollup merge of #62870 - matklad:issue-62863, r=petrochenkov

fix lexing of comments with many \r

closes #62863
This commit is contained in:
Mazdak Farrokhzad 2019-07-22 15:32:29 +02:00 committed by GitHub
commit 376382aff3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 31 additions and 1 deletions

View file

@ -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),

View file

@ -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 do c 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() {}

View file

@ -0,0 +1,20 @@
error: bare CR not allowed in doc-comment
--> $DIR/several-carriage-returns-in-doc-comment.rs:6:12
|
LL | /// This do c 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 do c 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 do c comment contains three isolated `\r` symbols
| ^
error: aborting due to 3 previous errors