Skip to content

Commit b15b0eb

Browse files
committed
Merge pull request #45 from MicahChalmer/backslash-and-double-quote-char-literals
Parse '\\' and '\"' as char literals
2 parents 22c8cfa + 766bd82 commit b15b0eb

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

rust-mode-tests.el

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -927,6 +927,22 @@ list of substrings of `STR' each followed by its face."
927927
"let" font-lock-keyword-face
928928
"'\\''" font-lock-string-face)))
929929

930+
(ert-deftest font-lock-escaped-double-quote-character-literal ()
931+
(rust-test-font-lock
932+
"fn main() { let ch = '\\\"'; }"
933+
'("fn" font-lock-keyword-face
934+
"main" font-lock-function-name-face
935+
"let" font-lock-keyword-face
936+
"'\\\"'" font-lock-string-face)))
937+
938+
(ert-deftest font-lock-escaped-backslash-character-literal ()
939+
(rust-test-font-lock
940+
"fn main() { let ch = '\\\\'; }"
941+
'("fn" font-lock-keyword-face
942+
"main" font-lock-function-name-face
943+
"let" font-lock-keyword-face
944+
"'\\\\'" font-lock-string-face)))
945+
930946
(ert-deftest font-lock-raw-strings-no-hashes ()
931947
(rust-test-font-lock
932948
"r\"No hashes\";"

rust-mode.el

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@
423423
;; Handle single quoted character literals:
424424
(mapcar (lambda (re) (list re '(1 "\"") '(2 "\"")))
425425
'("\\('\\)[^']\\('\\)"
426-
"\\('\\)\\\\['nrt]\\('\\)"
426+
"\\('\\)\\\\['nrt\"\\]\\('\\)"
427427
"\\('\\)\\\\x[[:xdigit:]]\\{2\\}\\('\\)"
428428
"\\('\\)\\\\u[[:xdigit:]]\\{4\\}\\('\\)"
429429
"\\('\\)\\\\U[[:xdigit:]]\\{8\\}\\('\\)"))

0 commit comments

Comments
 (0)