File tree Expand file tree Collapse file tree 1 file changed +18
-8
lines changed Expand file tree Collapse file tree 1 file changed +18
-8
lines changed Original file line number Diff line number Diff line change 101
101
(rust-push-context st 'string (current-column ) t )
102
102
(setf (rust-state-tokenize st) 'rust-token-string )
103
103
(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))
112
105
(def ?/ (forward-char )
113
106
(case (char-after )
114
107
(?/ (end-of-line ) 'font-lock-comment-face )
150
143
(setf rust-tcat 'op ) nil )
151
144
table)))
152
145
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
+
153
163
(defun rust-token-base (st )
154
164
(funcall (char-table-range rust-char-table (char-after )) st))
155
165
You can’t perform that action at this time.
0 commit comments