diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2018-12-27 12:12:14 +0000 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2018-12-27 12:12:14 +0000 |
commit | 55ab0c602e391537f5e1a84a617fdd817e6a4200 (patch) | |
tree | 3adb0077bd7d7a34376d87cbb0ae7ea5b942d532 /crates/ra_syntax/src/validation/byte_string.rs | |
parent | dbf03b674e7e1a49d9b32ec5ed656df2aedd3ed3 (diff) | |
parent | 49b0fe20ab6aa752df3764908b7c21f4b1827e52 (diff) |
Merge #339
339: Fix assertion error for literals with suffixes r=matklad a=matklad
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_syntax/src/validation/byte_string.rs')
-rw-r--r-- | crates/ra_syntax/src/validation/byte_string.rs | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/crates/ra_syntax/src/validation/byte_string.rs b/crates/ra_syntax/src/validation/byte_string.rs index 7b830e97c..f7a4fb156 100644 --- a/crates/ra_syntax/src/validation/byte_string.rs +++ b/crates/ra_syntax/src/validation/byte_string.rs | |||
@@ -17,21 +17,28 @@ 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 | ||
32 | if !components.has_closing_quote { | 32 | if !components.has_closing_quote { |
33 | errors.push(SyntaxError::new(UnclosedString, literal_range)); | 33 | errors.push(SyntaxError::new(UnclosedString, literal_range)); |
34 | } | 34 | } |
35 | |||
36 | if let Some(range) = components.suffix { | ||
37 | errors.push(SyntaxError::new( | ||
38 | InvalidSuffix, | ||
39 | range + literal_range.start(), | ||
40 | )); | ||
41 | } | ||
35 | } | 42 | } |
36 | 43 | ||
37 | #[cfg(test)] | 44 | #[cfg(test)] |