From 01db4cb55b43300375d21aaa7a99b682e53e915a Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Thu, 25 Feb 2016 08:25:01 +0100 Subject: Fix font-locking for Unicode escapes in character literals. * There is only \u, no \U * \u requires braces, but allows 1-6 hex digits --- 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 "'\\")) -- cgit v1.2.3