branch: elpa/rust-mode
commit 766bd8279b18bcbf6af0b8fea370c85414e407c4
Author: Micah Chalmer <[email protected]>
Commit: Micah Chalmer <[email protected]>
Parse '\\' and '\"' as char literals
---
rust-mode-tests.el | 16 ++++++++++++++++
rust-mode.el | 2 +-
2 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/rust-mode-tests.el b/rust-mode-tests.el
index 007d116..3510d69 100644
--- a/rust-mode-tests.el
+++ b/rust-mode-tests.el
@@ -927,6 +927,22 @@ list of substrings of `STR' each followed by its face."
"let" font-lock-keyword-face
"'\\''" font-lock-string-face)))
+(ert-deftest font-lock-escaped-double-quote-character-literal ()
+ (rust-test-font-lock
+ "fn main() { let ch = '\\\"'; }"
+ '("fn" font-lock-keyword-face
+ "main" font-lock-function-name-face
+ "let" font-lock-keyword-face
+ "'\\\"'" font-lock-string-face)))
+
+(ert-deftest font-lock-escaped-backslash-character-literal ()
+ (rust-test-font-lock
+ "fn main() { let ch = '\\\\'; }"
+ '("fn" font-lock-keyword-face
+ "main" font-lock-function-name-face
+ "let" font-lock-keyword-face
+ "'\\\\'" font-lock-string-face)))
+
(ert-deftest font-lock-raw-strings-no-hashes ()
(rust-test-font-lock
"r\"No hashes\";"
diff --git a/rust-mode.el b/rust-mode.el
index c82a484..9a6eb5f 100644
--- a/rust-mode.el
+++ b/rust-mode.el
@@ -423,7 +423,7 @@
;; Handle single quoted character literals:
(mapcar (lambda (re) (list re '(1 "\"") '(2 "\"")))
'("\\('\\)[^']\\('\\)"
- "\\('\\)\\\\['nrt]\\('\\)"
+ "\\('\\)\\\\['nrt\"\\]\\('\\)"
"\\('\\)\\\\x[[:xdigit:]]\\{2\\}\\('\\)"
"\\('\\)\\\\u[[:xdigit:]]\\{4\\}\\('\\)"
"\\('\\)\\\\U[[:xdigit:]]\\{8\\}\\('\\)"))