Skip to content

Commit 51b35cc

Browse files
committed
Add comments for why skip highlighting for invalid char/byte literals
1 parent 1f35e4d commit 51b35cc

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

crates/ide/src/syntax_highlighting/escape.rs

+4
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ pub(super) fn highlight_escape_string<T: IsString>(
2626

2727
pub(super) fn highlight_escape_char(stack: &mut Highlights, char: &Char, start: TextSize) {
2828
if char.value().is_none() {
29+
// We do not emit invalid escapes highlighting here. The lexer would likely be in a bad
30+
// state and this token contains junks, since `'` is not a reliable delimiter (consider
31+
// lifetimes). Nonetheless, parser errors should already be emitted.
2932
return;
3033
}
3134

@@ -46,6 +49,7 @@ pub(super) fn highlight_escape_char(stack: &mut Highlights, char: &Char, start:
4649

4750
pub(super) fn highlight_escape_byte(stack: &mut Highlights, byte: &Byte, start: TextSize) {
4851
if byte.value().is_none() {
52+
// See `highlight_escape_char` for why no error highlighting here.
4953
return;
5054
}
5155

0 commit comments

Comments
 (0)