diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2018-12-29 12:50:34 +0000 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2018-12-29 12:50:34 +0000 |
commit | 4a3d6aa26a1c71dadc91f37f9d5f8662b51c138a (patch) | |
tree | 5877d2665edf70dcc3398f90dffd11dc85aa37b8 /crates/ra_syntax/src | |
parent | 9220641ba4d3c7a95db7355d9999da54d455607c (diff) | |
parent | b67a4e7a57f5569de0de67d625b02378866ac3ec (diff) |
Merge #356
356: Fix a bug in char literal validation discovered through fuzzing r=matklad a=DJMcNab
We also add a Cargo.lock to the fuzzing directory, as that isn't gitignored automatically, so I imagine it should be committed.
Co-authored-by: DJMcNab <[email protected]>
Diffstat (limited to 'crates/ra_syntax/src')
-rw-r--r-- | crates/ra_syntax/src/string_lexing/parser.rs | 2 | ||||
-rw-r--r-- | crates/ra_syntax/src/validation/char.rs | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/crates/ra_syntax/src/string_lexing/parser.rs b/crates/ra_syntax/src/string_lexing/parser.rs index 14c6015c2..e835382fc 100644 --- a/crates/ra_syntax/src/string_lexing/parser.rs +++ b/crates/ra_syntax/src/string_lexing/parser.rs | |||
@@ -82,7 +82,7 @@ impl<'a> Parser<'a> { | |||
82 | 82 | ||
83 | fn parse_escape(&mut self, start: TextUnit) -> StringComponent { | 83 | fn parse_escape(&mut self, start: TextUnit) -> StringComponent { |
84 | if self.peek().is_none() { | 84 | if self.peek().is_none() { |
85 | return StringComponent::new(TextRange::from_to(start, start), AsciiEscape); | 85 | return StringComponent::new(TextRange::from_to(start, self.get_pos()), AsciiEscape); |
86 | } | 86 | } |
87 | 87 | ||
88 | let next = self.advance(); | 88 | let next = self.advance(); |
diff --git a/crates/ra_syntax/src/validation/char.rs b/crates/ra_syntax/src/validation/char.rs index 19cd3830f..10d3d1dec 100644 --- a/crates/ra_syntax/src/validation/char.rs +++ b/crates/ra_syntax/src/validation/char.rs | |||
@@ -70,7 +70,7 @@ pub(super) fn validate_char_component( | |||
70 | 70 | ||
71 | fn validate_ascii_escape(text: &str, range: TextRange, errors: &mut Vec<SyntaxError>) { | 71 | fn validate_ascii_escape(text: &str, range: TextRange, errors: &mut Vec<SyntaxError>) { |
72 | if text.len() == 1 { | 72 | if text.len() == 1 { |
73 | // Escape sequence consists only of leading `\` | 73 | // Escape sequence consists only of leading `\` (only occurs at EOF, otherwise e.g. '\' is treated as an unclosed char containing a single quote `'`) |
74 | errors.push(SyntaxError::new(EmptyAsciiEscape, range)); | 74 | errors.push(SyntaxError::new(EmptyAsciiEscape, range)); |
75 | } else { | 75 | } else { |
76 | let escape_code = text.chars().skip(1).next().unwrap(); | 76 | let escape_code = text.chars().skip(1).next().unwrap(); |