Skip to content

Commit 376382a

Browse files
authored
Rollup merge of #62870 - matklad:issue-62863, r=petrochenkov
fix lexing of comments with many \r closes #62863
2 parents e178a1e + 647bf96 commit 376382a

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed

src/libsyntax/parse/lexer/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ impl<'a> StringReader<'a> {
226226
loop {
227227
idx = match string[idx..].find('\r') {
228228
None => break,
229-
Some(it) => it + 1
229+
Some(it) => idx + it + 1
230230
};
231231
if string[idx..].chars().next() != Some('\n') {
232232
self.err_span_(start + BytePos(idx as u32 - 1),

src/test/ui/parser/several-carriage-returns-in-doc-comment.rs

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// Issue #62863
2+
// ignore-tidy-cr
3+
4+
// Note: if you see ^M in this file, that's how your editor renders literal `\r`
5+
6+
/// This doc comment contains three isolated `\r` symbols
7+
//~^ ERROR bare CR not allowed in doc-comment
8+
//~| ERROR bare CR not allowed in doc-comment
9+
//~| ERROR bare CR not allowed in doc-comment
10+
fn main() {}

src/test/ui/parser/several-carriage-returns-in-doc-comment.stderr

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
error: bare CR not allowed in doc-comment
2+
--> $DIR/several-carriage-returns-in-doc-comment.rs:6:12
3+
|
4+
LL | /// This doc comment contains three isolated `\r` symbols
5+
| ^
6+
7+
error: bare CR not allowed in doc-comment
8+
--> $DIR/several-carriage-returns-in-doc-comment.rs:6:32
9+
|
10+
LL | /// This doc comment contains three isolated `\r` symbols
11+
| ^
12+
13+
error: bare CR not allowed in doc-comment
14+
--> $DIR/several-carriage-returns-in-doc-comment.rs:6:52
15+
|
16+
LL | /// This doc comment contains three isolated `\r` symbols
17+
| ^
18+
19+
error: aborting due to 3 previous errors
20+

0 commit comments

Comments
 (0)