aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_syntax/src')
-rw-r--r--crates/ra_syntax/src/validation/char.rs12
1 files changed, 9 insertions, 3 deletions
diff --git a/crates/ra_syntax/src/validation/char.rs b/crates/ra_syntax/src/validation/char.rs
index 10d3d1dec..3b1b91230 100644
--- a/crates/ra_syntax/src/validation/char.rs
+++ b/crates/ra_syntax/src/validation/char.rs
@@ -89,12 +89,18 @@ pub(super) fn is_ascii_escape(code: char) -> bool {
89 89
90fn validate_ascii_code_escape(text: &str, range: TextRange, errors: &mut Vec<SyntaxError>) { 90fn validate_ascii_code_escape(text: &str, range: TextRange, errors: &mut Vec<SyntaxError>) {
91 // An AsciiCodeEscape has 4 chars, example: `\xDD` 91 // An AsciiCodeEscape has 4 chars, example: `\xDD`
92 if !text.is_ascii() {
93 // TODO: Give a more precise error message (say what the invalid character was)
94 errors.push(SyntaxError::new(AsciiCodeEscapeOutOfRange, range));
95 }
92 if text.len() < 4 { 96 if text.len() < 4 {
93 errors.push(SyntaxError::new(TooShortAsciiCodeEscape, range)); 97 errors.push(SyntaxError::new(TooShortAsciiCodeEscape, range));
94 } else { 98 } else {
95 assert!( 99 assert_eq!(
96 text.chars().count() == 4, 100 text.len(),
97 "AsciiCodeEscape cannot be longer than 4 chars" 101 4,
102 "AsciiCodeEscape cannot be longer than 4 chars, but text '{}' is",
103 text,
98 ); 104 );
99 105
100 match u8::from_str_radix(&text[2..], 16) { 106 match u8::from_str_radix(&text[2..], 16) {