diff options
| author | oxalica <oxalicc@pm.me> | 2023-07-23 04:24:35 +0800 |
|---|---|---|
| committer | oxalica <oxalicc@pm.me> | 2023-07-23 04:24:35 +0800 |
| commit | 51b35ccb1b134d511cd29ea4a06c8d1abaaffabb (patch) | |
| tree | 9fc89fc794edcbc3258396c95b31c2aadd3af6ea | |
| parent | 1f35e4d3f1a741b4fd7468dd62eaac7b14f184a7 (diff) | |
| download | rust-51b35ccb1b134d511cd29ea4a06c8d1abaaffabb.tar.gz rust-51b35ccb1b134d511cd29ea4a06c8d1abaaffabb.zip | |
Add comments for why skip highlighting for invalid char/byte literals
| -rw-r--r-- | crates/ide/src/syntax_highlighting/escape.rs | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/crates/ide/src/syntax_highlighting/escape.rs b/crates/ide/src/syntax_highlighting/escape.rs index 41b27683f6c..5913ca5e454 100644 --- a/crates/ide/src/syntax_highlighting/escape.rs +++ b/crates/ide/src/syntax_highlighting/escape.rs @@ -26,6 +26,9 @@ pub(super) fn highlight_escape_string<T: IsString>( pub(super) fn highlight_escape_char(stack: &mut Highlights, char: &Char, start: TextSize) { if char.value().is_none() { + // We do not emit invalid escapes highlighting here. The lexer would likely be in a bad + // state and this token contains junks, since `'` is not a reliable delimiter (consider + // lifetimes). Nonetheless, parser errors should already be emitted. return; } @@ -46,6 +49,7 @@ pub(super) fn highlight_escape_char(stack: &mut Highlights, char: &Char, start: pub(super) fn highlight_escape_byte(stack: &mut Highlights, byte: &Byte, start: TextSize) { if byte.value().is_none() { + // See `highlight_escape_char` for why no error highlighting here. return; } |
