Skip to content

Commit f847211

Browse files
hkBstfolkertdev
andauthored
use bytes also for initial newline
Co-authored-by: Folkert de Vries <[email protected]>
1 parent 258115e commit f847211

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

compiler/rustc_lexer/src/unescape.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -356,10 +356,9 @@ where
356356
let start = src.len() - chars.as_str().len() - c.len_utf8();
357357
let res = match c {
358358
'\\' => {
359-
let mut chars_clone = chars.clone();
360-
match chars_clone.next() {
361-
Some('\n') => {
362-
chars = chars_clone;
359+
match chars.as_str().as_bytes().get(1) {
360+
Some(b'\n') => {
361+
let _ = chars.next();
363362
// Rust language specification requires us to skip whitespaces
364363
// if unescaped '\' character is followed by '\n'.
365364
// For details see [Rust language reference]

0 commit comments

Comments
 (0)