aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src/validation/char.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_syntax/src/validation/char.rs')
-rw-r--r--crates/ra_syntax/src/validation/char.rs14
1 files changed, 11 insertions, 3 deletions
diff --git a/crates/ra_syntax/src/validation/char.rs b/crates/ra_syntax/src/validation/char.rs
index 4728c85e6..19cd3830f 100644
--- a/crates/ra_syntax/src/validation/char.rs
+++ b/crates/ra_syntax/src/validation/char.rs
@@ -6,7 +6,7 @@ use arrayvec::ArrayString;
6 6
7use crate::{ 7use crate::{
8 ast::{self, AstNode}, 8 ast::{self, AstNode},
9 string_lexing::{self, CharComponentKind}, 9 string_lexing::{self, StringComponentKind},
10 TextRange, 10 TextRange,
11 yellow::{ 11 yellow::{
12 SyntaxError, 12 SyntaxError,
@@ -30,6 +30,13 @@ pub(super) fn validate_char_node(node: ast::Char, errors: &mut Vec<SyntaxError>)
30 errors.push(SyntaxError::new(UnclosedChar, literal_range)); 30 errors.push(SyntaxError::new(UnclosedChar, literal_range));
31 } 31 }
32 32
33 if let Some(range) = components.suffix {
34 errors.push(SyntaxError::new(
35 InvalidSuffix,
36 range + literal_range.start(),
37 ));
38 }
39
33 if len == 0 { 40 if len == 0 {
34 errors.push(SyntaxError::new(EmptyChar, literal_range)); 41 errors.push(SyntaxError::new(EmptyChar, literal_range));
35 } 42 }
@@ -41,12 +48,12 @@ pub(super) fn validate_char_node(node: ast::Char, errors: &mut Vec<SyntaxError>)
41 48
42pub(super) fn validate_char_component( 49pub(super) fn validate_char_component(
43 text: &str, 50 text: &str,
44 kind: CharComponentKind, 51 kind: StringComponentKind,
45 range: TextRange, 52 range: TextRange,
46 errors: &mut Vec<SyntaxError>, 53 errors: &mut Vec<SyntaxError>,
47) { 54) {
48 // Validate escapes 55 // Validate escapes
49 use self::CharComponentKind::*; 56 use self::StringComponentKind::*;
50 match kind { 57 match kind {
51 AsciiEscape => validate_ascii_escape(text, range, errors), 58 AsciiEscape => validate_ascii_escape(text, range, errors),
52 AsciiCodeEscape => validate_ascii_code_escape(text, range, errors), 59 AsciiCodeEscape => validate_ascii_code_escape(text, range, errors),
@@ -57,6 +64,7 @@ pub(super) fn validate_char_component(
57 errors.push(SyntaxError::new(UnescapedCodepoint, range)); 64 errors.push(SyntaxError::new(UnescapedCodepoint, range));
58 } 65 }
59 } 66 }
67 StringComponentKind::IgnoreNewline => { /* always valid */ }
60 } 68 }
61} 69}
62 70