branch: elpa/rust-mode
commit 6739dd9d6312f231a9a9ed550939994adca271d6
Merge: 00e5366 01db4cb
Author: Niko Matsakis <[email protected]>
Commit: Niko Matsakis <[email protected]>
Merge pull request #123 from birkenfeld/fix-unicode-char-escapes
Fix font-locking for Unicode escapes in character literals.
---
rust-mode-tests.el | 12 ++++++++++++
rust-mode.el | 3 +--
2 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/rust-mode-tests.el b/rust-mode-tests.el
index 8390ab6..a99d36b 100644
--- a/rust-mode-tests.el
+++ b/rust-mode-tests.el
@@ -1217,6 +1217,18 @@ list of substrings of `STR' each followed by its face."
"let" font-lock-keyword-face
"'\\\\'" font-lock-string-face)))
+(ert-deftest font-lock-hex-escape-character-literal ()
+ (rust-test-font-lock
+ "let ch = '\\x1f';"
+ '("let" font-lock-keyword-face
+ "'\\x1f'" font-lock-string-face)))
+
+(ert-deftest font-lock-unicode-escape-character-literal ()
+ (rust-test-font-lock
+ "let ch = '\\u{1ffff}';"
+ '("let" font-lock-keyword-face
+ "'\\u{1ffff}'" 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 686498b..56b356d 100644
--- a/rust-mode.el
+++ b/rust-mode.el
@@ -83,8 +83,7 @@
(seq
"\\"
(or
- (: "U" (= 8 xdigit))
- (: "u" (= 4 xdigit))
+ (: "u{" (** 1 6 xdigit) "}")
(: "x" (= 2 xdigit))
(any "'nrt0\"\\")))
(not (any "'\\"))