Skip to content

Commit d6f722d

Browse files
committed
librustc_lexer: Simplify "double_quoted_string" method
1 parent 649a524 commit d6f722d

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/librustc_lexer/src/lib.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -580,20 +580,20 @@ impl Cursor<'_> {
580580
/// if string is terminated.
581581
fn double_quoted_string(&mut self) -> bool {
582582
debug_assert!(self.prev() == '"');
583-
loop {
584-
match self.nth_char(0) {
583+
while let Some(c) = self.bump() {
584+
match c {
585585
'"' => {
586-
self.bump();
587586
return true;
588587
}
589-
EOF_CHAR if self.is_eof() => return false,
590-
'\\' if self.nth_char(1) == '\\' || self.nth_char(1) == '"' => {
588+
'\\' if self.first() == '\\' || self.first() == '"' => {
589+
// Bump again to skip escaped character.
591590
self.bump();
592591
}
593592
_ => (),
594593
}
595-
self.bump();
596594
}
595+
// End of file reached.
596+
false
597597
}
598598

599599
/// Eats the double-quoted string and returns a tuple of

0 commit comments

Comments
 (0)