diff options
author | Adolfo OchagavĂa <[email protected]> | 2018-11-11 20:00:31 +0000 |
---|---|---|
committer | Adolfo OchagavĂa <[email protected]> | 2018-11-11 20:00:31 +0000 |
commit | c96bfe7e2d4465653fe6b0eff053f0dfb48313fa (patch) | |
tree | 93c56d8301131a01de13b73010f615291eb1d6d4 /crates/ra_syntax/src/validation/byte.rs | |
parent | 30cd4d5acb7dfd40cea264a926d1c89f0c3522c3 (diff) |
Split string lexing and run rustfmt
Diffstat (limited to 'crates/ra_syntax/src/validation/byte.rs')
-rw-r--r-- | crates/ra_syntax/src/validation/byte.rs | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/crates/ra_syntax/src/validation/byte.rs b/crates/ra_syntax/src/validation/byte.rs index 7baf3c1d7..43c0d7edd 100644 --- a/crates/ra_syntax/src/validation/byte.rs +++ b/crates/ra_syntax/src/validation/byte.rs | |||
@@ -48,7 +48,10 @@ pub(super) fn validate_byte_component( | |||
48 | AsciiCodeEscape => validate_byte_code_escape(text, range, errors), | 48 | AsciiCodeEscape => validate_byte_code_escape(text, range, errors), |
49 | UnicodeEscape => errors.push(SyntaxError::new(UnicodeEscapeForbidden, range)), | 49 | UnicodeEscape => errors.push(SyntaxError::new(UnicodeEscapeForbidden, range)), |
50 | CodePoint => { | 50 | CodePoint => { |
51 | let c = text.chars().next().expect("Code points should be one character long"); | 51 | let c = text |
52 | .chars() | ||
53 | .next() | ||
54 | .expect("Code points should be one character long"); | ||
52 | 55 | ||
53 | // These bytes must always be escaped | 56 | // These bytes must always be escaped |
54 | if c == '\t' || c == '\r' || c == '\n' { | 57 | if c == '\t' || c == '\r' || c == '\n' { |
@@ -148,9 +151,7 @@ mod test { | |||
148 | 151 | ||
149 | #[test] | 152 | #[test] |
150 | fn test_valid_byte_escape() { | 153 | fn test_valid_byte_escape() { |
151 | let valid = [ | 154 | let valid = [r"\'", "\"", "\\\\", "\\\"", r"\n", r"\r", r"\t", r"\0"]; |
152 | r"\'", "\"", "\\\\", "\\\"", r"\n", r"\r", r"\t", r"\0", | ||
153 | ]; | ||
154 | for c in &valid { | 155 | for c in &valid { |
155 | assert_valid_byte(c); | 156 | assert_valid_byte(c); |
156 | } | 157 | } |