Skip to content

Commit 22bf66f

Browse files
committed
Allow carriage return in raw string if followed by newline
1 parent 0af589a commit 22bf66f

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/parse.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -449,13 +449,17 @@ fn raw_string(input: Cursor) -> Result<Cursor, LexError> {
449449
_ => return Err(LexError),
450450
}
451451
}
452-
for (i, ch) in chars {
452+
while let Some((i, ch)) = chars.next() {
453453
match ch {
454454
'"' if input.rest[i + 1..].starts_with(&input.rest[..n]) => {
455455
let rest = input.advance(i + 1 + n);
456456
return Ok(literal_suffix(rest));
457457
}
458-
'\r' => return Err(LexError),
458+
'\r' => {
459+
if chars.next().map_or(true, |(_, ch)| ch != '\n') {
460+
return Err(LexError);
461+
}
462+
}
459463
_ => {}
460464
}
461465
}

0 commit comments

Comments
 (0)