Skip to content

Commit b8d1bb8

Browse files
committed
---
yaml --- r: 47723 b: refs/heads/incoming c: 1ef8c48 h: refs/heads/master i: 47721: b88ef83 47719: 8536b11 v: v3
1 parent 5abadc8 commit b8d1bb8

File tree

2 files changed

+19
-9
lines changed

2 files changed

+19
-9
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ refs/heads/try: 2a8fb58d79e685d5ca07b039badcf2ae3ef077ea
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
9-
refs/heads/incoming: c7f85003a345826b17801d473303d0c545d0e8d2
9+
refs/heads/incoming: 1ef8c48a204ad215310f38a239a898ee38d9bf8e
1010
refs/heads/dist-snap: 8b98e5a296d95c5e832db0756828e5bec31c6f50
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/incoming/src/etc/emacs/rust-mode.el

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,7 @@
101101
(rust-push-context st 'string (current-column) t)
102102
(setf (rust-state-tokenize st) 'rust-token-string)
103103
(rust-token-string st))
104-
(def ?\' (forward-char)
105-
(setf rust-tcat 'atom)
106-
(let ((is-escape (eq (char-after) ?\\))
107-
(start (point)))
108-
(if (not (rust-eat-until-unescaped ?\'))
109-
'font-lock-warning-face
110-
(if (or is-escape (= (point) (+ start 2)))
111-
'font-lock-string-face 'font-lock-warning-face))))
104+
(def ?\' (rust-single-quote))
112105
(def ?/ (forward-char)
113106
(case (char-after)
114107
(?/ (end-of-line) 'font-lock-comment-face)
@@ -150,6 +143,23 @@
150143
(setf rust-tcat 'op) nil)
151144
table)))
152145

146+
(defun rust-single-quote ()
147+
(forward-char)
148+
(setf rust-tcat 'atom)
149+
; Is this a lifetime?
150+
(if (or (looking-at "[a-zA-Z_]$")
151+
(looking-at "[a-zA-Z_][^']"))
152+
; If what we see is 'abc, use font-lock-type-face:
153+
(progn (rust-eat-re "[a-zA-Z_][a-zA-Z_0-9]*")
154+
'font-lock-type-face)
155+
; Otherwise, handle as a character constant:
156+
(let ((is-escape (eq (char-after) ?\\))
157+
(start (point)))
158+
(if (not (rust-eat-until-unescaped ?\'))
159+
'font-lock-warning-face
160+
(if (or is-escape (= (point) (+ start 2)))
161+
'font-lock-string-face 'font-lock-warning-face)))))
162+
153163
(defun rust-token-base (st)
154164
(funcall (char-table-range rust-char-table (char-after)) st))
155165

0 commit comments

Comments
 (0)