mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-29 13:25:09 +00:00
Finish implementing char validation
This commit is contained in:
parent
d1b242262a
commit
c56db92d1f
3 changed files with 93 additions and 8 deletions
|
@ -69,6 +69,14 @@ pub enum SyntaxErrorKind {
|
|||
LongChar,
|
||||
EmptyAsciiEscape,
|
||||
InvalidAsciiEscape,
|
||||
TooShortAsciiCodeEscape,
|
||||
AsciiCodeEscapeOutOfRange,
|
||||
MalformedAsciiCodeEscape,
|
||||
UnclosedUnicodeEscape,
|
||||
MalformedUnicodeEscape,
|
||||
EmptyUnicodeEcape,
|
||||
OverlongUnicodeEscape,
|
||||
UnicodeEscapeOutOfRange,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
|
@ -83,6 +91,14 @@ impl fmt::Display for SyntaxErrorKind {
|
|||
EmptyChar => write!(f, "Empty char literal"),
|
||||
UnclosedChar => write!(f, "Unclosed char literal"),
|
||||
LongChar => write!(f, "Char literal should be one character long"),
|
||||
TooShortAsciiCodeEscape => write!(f, "Escape sequence should have two digits"),
|
||||
AsciiCodeEscapeOutOfRange => write!(f, "Escape sequence should be between \\x00 and \\x7F"),
|
||||
MalformedAsciiCodeEscape => write!(f, "Escape sequence should be a hexadecimal number"),
|
||||
UnclosedUnicodeEscape => write!(f, "Missing `}}`"),
|
||||
MalformedUnicodeEscape => write!(f, "Malformed unicode escape sequence"),
|
||||
EmptyUnicodeEcape => write!(f, "Empty unicode escape sequence"),
|
||||
OverlongUnicodeEscape => write!(f, "Unicode escape sequence should have at most 6 digits"),
|
||||
UnicodeEscapeOutOfRange => write!(f, "Unicode escape code should be at most 0x10FFFF"),
|
||||
ParseError(msg) => write!(f, "{}", msg.0),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue