aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src/validation
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_syntax/src/validation')
-rw-r--r--crates/ra_syntax/src/validation/byte.rs7
-rw-r--r--crates/ra_syntax/src/validation/byte_string.rs6
-rw-r--r--crates/ra_syntax/src/validation/char.rs7
-rw-r--r--crates/ra_syntax/src/validation/string.rs17
4 files changed, 17 insertions, 20 deletions
diff --git a/crates/ra_syntax/src/validation/byte.rs b/crates/ra_syntax/src/validation/byte.rs
index 43c0d7edd..e3603e761 100644
--- a/crates/ra_syntax/src/validation/byte.rs
+++ b/crates/ra_syntax/src/validation/byte.rs
@@ -2,7 +2,7 @@
2 2
3use crate::{ 3use crate::{
4 ast::{self, AstNode}, 4 ast::{self, AstNode},
5 string_lexing::{self, CharComponentKind}, 5 string_lexing::{self, StringComponentKind},
6 TextRange, 6 TextRange,
7 validation::char, 7 validation::char,
8 yellow::{ 8 yellow::{
@@ -38,11 +38,11 @@ pub(super) fn validate_byte_node(node: ast::Byte, errors: &mut Vec<SyntaxError>)
38 38
39pub(super) fn validate_byte_component( 39pub(super) fn validate_byte_component(
40 text: &str, 40 text: &str,
41 kind: CharComponentKind, 41 kind: StringComponentKind,
42 range: TextRange, 42 range: TextRange,
43 errors: &mut Vec<SyntaxError>, 43 errors: &mut Vec<SyntaxError>,
44) { 44) {
45 use self::CharComponentKind::*; 45 use self::StringComponentKind::*;
46 match kind { 46 match kind {
47 AsciiEscape => validate_byte_escape(text, range, errors), 47 AsciiEscape => validate_byte_escape(text, range, errors),
48 AsciiCodeEscape => validate_byte_code_escape(text, range, errors), 48 AsciiCodeEscape => validate_byte_code_escape(text, range, errors),
@@ -63,6 +63,7 @@ pub(super) fn validate_byte_component(
63 errors.push(SyntaxError::new(ByteOutOfRange, range)); 63 errors.push(SyntaxError::new(ByteOutOfRange, range));
64 } 64 }
65 } 65 }
66 IgnoreNewline => { /* always valid */ }
66 } 67 }
67} 68}
68 69
diff --git a/crates/ra_syntax/src/validation/byte_string.rs b/crates/ra_syntax/src/validation/byte_string.rs
index 7b830e97c..2f98472f4 100644
--- a/crates/ra_syntax/src/validation/byte_string.rs
+++ b/crates/ra_syntax/src/validation/byte_string.rs
@@ -17,15 +17,15 @@ pub(crate) fn validate_byte_string_node(node: ast::ByteString, errors: &mut Vec<
17 let range = component.range + literal_range.start(); 17 let range = component.range + literal_range.start();
18 18
19 match component.kind { 19 match component.kind {
20 StringComponentKind::Char(kind) => { 20 StringComponentKind::IgnoreNewline => { /* always valid */ }
21 _ => {
21 // Chars must escape \t, \n and \r codepoints, but strings don't 22 // Chars must escape \t, \n and \r codepoints, but strings don't
22 let text = &literal_text[component.range]; 23 let text = &literal_text[component.range];
23 match text { 24 match text {
24 "\t" | "\n" | "\r" => { /* always valid */ } 25 "\t" | "\n" | "\r" => { /* always valid */ }
25 _ => byte::validate_byte_component(text, kind, range, errors), 26 _ => byte::validate_byte_component(text, component.kind, range, errors),
26 } 27 }
27 } 28 }
28 StringComponentKind::IgnoreNewline => { /* always valid */ }
29 } 29 }
30 } 30 }
31 31
diff --git a/crates/ra_syntax/src/validation/char.rs b/crates/ra_syntax/src/validation/char.rs
index 4728c85e6..deb5b0a9e 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,
@@ -41,12 +41,12 @@ pub(super) fn validate_char_node(node: ast::Char, errors: &mut Vec<SyntaxError>)
41 41
42pub(super) fn validate_char_component( 42pub(super) fn validate_char_component(
43 text: &str, 43 text: &str,
44 kind: CharComponentKind, 44 kind: StringComponentKind,
45 range: TextRange, 45 range: TextRange,
46 errors: &mut Vec<SyntaxError>, 46 errors: &mut Vec<SyntaxError>,
47) { 47) {
48 // Validate escapes 48 // Validate escapes
49 use self::CharComponentKind::*; 49 use self::StringComponentKind::*;
50 match kind { 50 match kind {
51 AsciiEscape => validate_ascii_escape(text, range, errors), 51 AsciiEscape => validate_ascii_escape(text, range, errors),
52 AsciiCodeEscape => validate_ascii_code_escape(text, range, errors), 52 AsciiCodeEscape => validate_ascii_code_escape(text, range, errors),
@@ -57,6 +57,7 @@ pub(super) fn validate_char_component(
57 errors.push(SyntaxError::new(UnescapedCodepoint, range)); 57 errors.push(SyntaxError::new(UnescapedCodepoint, range));
58 } 58 }
59 } 59 }
60 StringComponentKind::IgnoreNewline => { /* always valid */ }
60 } 61 }
61} 62}
62 63
diff --git a/crates/ra_syntax/src/validation/string.rs b/crates/ra_syntax/src/validation/string.rs
index 089879d15..456180ab6 100644
--- a/crates/ra_syntax/src/validation/string.rs
+++ b/crates/ra_syntax/src/validation/string.rs
@@ -1,6 +1,6 @@
1use crate::{ 1use 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,16 +16,11 @@ 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