diff --git a/crates/libsyntax2/src/lexer/strings.rs b/crates/libsyntax2/src/lexer/strings.rs index a6da97d47e1..e6ade54a4a5 100644 --- a/crates/libsyntax2/src/lexer/strings.rs +++ b/crates/libsyntax2/src/lexer/strings.rs @@ -102,23 +102,11 @@ pub(crate) fn scan_raw_string(ptr: &mut Ptr) { } fn scan_byte(ptr: &mut Ptr) { - if ptr.next_is('\'') { - ptr.bump(); - return; - } - ptr.bump(); - if ptr.next_is('\'') { - ptr.bump(); - return; - } + scan_char(ptr) } fn scan_byte_string(ptr: &mut Ptr) { - while let Some(c) = ptr.bump() { - if c == '"' { - return; - } - } + scan_string(ptr) } fn scan_raw_byte_string(ptr: &mut Ptr) { diff --git a/crates/libsyntax2/tests/data/lexer/0008_byte_strings.rs b/crates/libsyntax2/tests/data/lexer/0008_byte_strings.rs index 9dd1570de77..b54930f5e69 100644 --- a/crates/libsyntax2/tests/data/lexer/0008_byte_strings.rs +++ b/crates/libsyntax2/tests/data/lexer/0008_byte_strings.rs @@ -1,2 +1,3 @@ b'' b'x' b"foo" br"" b''suf b""ix br""br +b'\n' b'\\' b'\'' b'hello' diff --git a/crates/libsyntax2/tests/data/lexer/0008_byte_strings.txt b/crates/libsyntax2/tests/data/lexer/0008_byte_strings.txt index ed8cd4babda..bc03b51a8ab 100644 --- a/crates/libsyntax2/tests/data/lexer/0008_byte_strings.txt +++ b/crates/libsyntax2/tests/data/lexer/0008_byte_strings.txt @@ -12,3 +12,11 @@ BYTE_STRING 5 "b\"\"ix" WHITESPACE 1 " " RAW_BYTE_STRING 6 "br\"\"br" WHITESPACE 1 "\n" +BYTE 5 "b\'\\n\'" +WHITESPACE 1 " " +BYTE 5 "b\'\\\\\'" +WHITESPACE 1 " " +BYTE 5 "b\'\\\'\'" +WHITESPACE 1 " " +BYTE 8 "b\'hello\'" +WHITESPACE 1 "\n"