diff options
Diffstat (limited to 'crates/ra_syntax/src/validation/string.rs')
-rw-r--r-- | crates/ra_syntax/src/validation/string.rs | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/crates/ra_syntax/src/validation/string.rs b/crates/ra_syntax/src/validation/string.rs index 089879d15..1371bb1f0 100644 --- a/crates/ra_syntax/src/validation/string.rs +++ b/crates/ra_syntax/src/validation/string.rs | |||
@@ -1,6 +1,6 @@ | |||
1 | use crate::{ | 1 | use crate::{ |
2 | ast::{self, AstNode}, | 2 | ast::{self, AstNode}, |
3 | string_lexing::{self, StringComponentKind}, | 3 | string_lexing, |
4 | yellow::{ | 4 | yellow::{ |
5 | SyntaxError, | 5 | SyntaxError, |
6 | SyntaxErrorKind::*, | 6 | SyntaxErrorKind::*, |
@@ -16,22 +16,24 @@ pub(crate) fn validate_string_node(node: ast::String, errors: &mut Vec<SyntaxErr | |||
16 | for component in &mut components { | 16 | for component in &mut components { |
17 | let range = component.range + literal_range.start(); | 17 | let range = component.range + literal_range.start(); |
18 | 18 | ||
19 | match component.kind { | 19 | // Chars must escape \t, \n and \r codepoints, but strings don't |
20 | StringComponentKind::Char(kind) => { | 20 | let text = &literal_text[component.range]; |
21 | // Chars must escape \t, \n and \r codepoints, but strings don't | 21 | match text { |
22 | let text = &literal_text[component.range]; | 22 | "\t" | "\n" | "\r" => { /* always valid */ } |
23 | match text { | 23 | _ => char::validate_char_component(text, component.kind, range, errors), |
24 | "\t" | "\n" | "\r" => { /* always valid */ } | ||
25 | _ => char::validate_char_component(text, kind, range, errors), | ||
26 | } | ||
27 | } | ||
28 | StringComponentKind::IgnoreNewline => { /* always valid */ } | ||
29 | } | 24 | } |
30 | } | 25 | } |
31 | 26 | ||
32 | if !components.has_closing_quote { | 27 | if !components.has_closing_quote { |
33 | errors.push(SyntaxError::new(UnclosedString, literal_range)); | 28 | errors.push(SyntaxError::new(UnclosedString, literal_range)); |
34 | } | 29 | } |
30 | |||
31 | if let Some(range) = components.suffix { | ||
32 | errors.push(SyntaxError::new( | ||
33 | InvalidSuffix, | ||
34 | range + literal_range.start(), | ||
35 | )); | ||
36 | } | ||
35 | } | 37 | } |
36 | 38 | ||
37 | #[cfg(test)] | 39 | #[cfg(test)] |