fix: use unescape_byte function for Byte literals

This commit is contained in:
Pol Valletbó 2023-10-11 13:09:12 +02:00
parent f58a8250dc
commit 677e6f3439
3 changed files with 12 additions and 21 deletions

View file

@ -274,7 +274,7 @@ impl<'a> Converter<'a> {
let text = &self.res.text[self.offset + 2..][..len - 2];
let i = text.rfind('\'').unwrap();
let text = &text[..i];
if let Err(e) = rustc_lexer::unescape::unescape_char(text) {
if let Err(e) = rustc_lexer::unescape::unescape_byte(text) {
err = error_to_diagnostic_message(e, Mode::Byte);
}
}

View file

@ -22,9 +22,9 @@ BYTE "b'\\'a'" error: character literal may only contain one codepoint
WHITESPACE "\n"
BYTE "b'\\0a'" error: character literal may only contain one codepoint
WHITESPACE "\n"
BYTE "b'\\u{0}x'" error: character literal may only contain one codepoint
BYTE "b'\\u{0}x'" error: unicode escape in byte string
WHITESPACE "\n"
BYTE "b'\\u{1F63b}}'" error: character literal may only contain one codepoint
BYTE "b'\\u{1F63b}}'" error: unicode escape in byte string
WHITESPACE "\n"
BYTE "b'\\v'" error: unknown byte escape
WHITESPACE "\n"
@ -50,12 +50,6 @@ BYTE "b'\\x🦀'" error: invalid character in numeric character escape
WHITESPACE "\n"
BYTE "b'\\xtt'" error: invalid character in numeric character escape
WHITESPACE "\n"
BYTE "b'\\xff'" error: out of range hex escape
WHITESPACE "\n"
BYTE "b'\\xFF'" error: out of range hex escape
WHITESPACE "\n"
BYTE "b'\\x80'" error: out of range hex escape
WHITESPACE "\n"
BYTE "b'\\u'" error: incorrect unicode escape sequence
WHITESPACE "\n"
BYTE "b'\\u[0123]'" error: incorrect unicode escape sequence
@ -72,21 +66,21 @@ BYTE "b'\\u{_0000}'" error: invalid start of unicode escape
WHITESPACE "\n"
BYTE "b'\\u{0000000}'" error: overlong unicode escape
WHITESPACE "\n"
BYTE "b'\\u{FFFFFF}'" error: invalid unicode character escape
BYTE "b'\\u{FFFFFF}'" error: unicode escape in byte string
WHITESPACE "\n"
BYTE "b'\\u{ffffff}'" error: invalid unicode character escape
BYTE "b'\\u{ffffff}'" error: unicode escape in byte string
WHITESPACE "\n"
BYTE "b'\\u{ffffff}'" error: invalid unicode character escape
BYTE "b'\\u{ffffff}'" error: unicode escape in byte string
WHITESPACE "\n"
BYTE "b'\\u{DC00}'" error: invalid unicode character escape
BYTE "b'\\u{DC00}'" error: unicode escape in byte string
WHITESPACE "\n"
BYTE "b'\\u{DDDD}'" error: invalid unicode character escape
BYTE "b'\\u{DDDD}'" error: unicode escape in byte string
WHITESPACE "\n"
BYTE "b'\\u{DFFF}'" error: invalid unicode character escape
BYTE "b'\\u{DFFF}'" error: unicode escape in byte string
WHITESPACE "\n"
BYTE "b'\\u{D800}'" error: invalid unicode character escape
BYTE "b'\\u{D800}'" error: unicode escape in byte string
WHITESPACE "\n"
BYTE "b'\\u{DAAA}'" error: invalid unicode character escape
BYTE "b'\\u{DAAA}'" error: unicode escape in byte string
WHITESPACE "\n"
BYTE "b'\\u{DBFF}'" error: invalid unicode character escape
BYTE "b'\\u{DBFF}'" error: unicode escape in byte string
WHITESPACE "\n"

View file

@ -25,9 +25,6 @@ b'\xx'
b'\'
b'\x🦀'
b'\xtt'
b'\xff'
b'\xFF'
b'\x80'
b'\u'
b'\u[0123]'
b'\u{0x}'