mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-03 07:04:49 +00:00
Use an else if
This commit is contained in:
parent
72ab6f7727
commit
0fd87cbc47
1 changed files with 2 additions and 3 deletions
|
@ -92,12 +92,11 @@ fn validate_ascii_code_escape(text: &str, range: TextRange, errors: &mut Vec<Syn
|
||||||
if !text.is_ascii() {
|
if !text.is_ascii() {
|
||||||
// TODO: Give a more precise error message (say what the invalid character was)
|
// TODO: Give a more precise error message (say what the invalid character was)
|
||||||
errors.push(SyntaxError::new(AsciiCodeEscapeOutOfRange, range));
|
errors.push(SyntaxError::new(AsciiCodeEscapeOutOfRange, range));
|
||||||
}
|
} else if text.chars().count() < 4 {
|
||||||
if text.len() < 4 {
|
|
||||||
errors.push(SyntaxError::new(TooShortAsciiCodeEscape, range));
|
errors.push(SyntaxError::new(TooShortAsciiCodeEscape, range));
|
||||||
} else {
|
} else {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
text.len(),
|
text.chars().count(),
|
||||||
4,
|
4,
|
||||||
"AsciiCodeEscape cannot be longer than 4 chars, but text '{}' is",
|
"AsciiCodeEscape cannot be longer than 4 chars, but text '{}' is",
|
||||||
text,
|
text,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue