Skip to content

Commit 01db4cb

Browse files
committed
Fix font-locking for Unicode escapes in character literals.
* There is only \u, no \U * \u requires braces, but allows 1-6 hex digits
1 parent 00e5366 commit 01db4cb

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

rust-mode-tests.el

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1217,6 +1217,18 @@ list of substrings of `STR' each followed by its face."
12171217
"let" font-lock-keyword-face
12181218
"'\\\\'" font-lock-string-face)))
12191219

1220+
(ert-deftest font-lock-hex-escape-character-literal ()
1221+
(rust-test-font-lock
1222+
"let ch = '\\x1f';"
1223+
'("let" font-lock-keyword-face
1224+
"'\\x1f'" font-lock-string-face)))
1225+
1226+
(ert-deftest font-lock-unicode-escape-character-literal ()
1227+
(rust-test-font-lock
1228+
"let ch = '\\u{1ffff}';"
1229+
'("let" font-lock-keyword-face
1230+
"'\\u{1ffff}'" font-lock-string-face)))
1231+
12201232
(ert-deftest font-lock-raw-strings-no-hashes ()
12211233
(rust-test-font-lock
12221234
"r\"No hashes\";"

rust-mode.el

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,7 @@
8383
(seq
8484
"\\"
8585
(or
86-
(: "U" (= 8 xdigit))
87-
(: "u" (= 4 xdigit))
86+
(: "u{" (** 1 6 xdigit) "}")
8887
(: "x" (= 2 xdigit))
8988
(any "'nrt0\"\\")))
9089
(not (any "'\\"))

0 commit comments

Comments
 (0)