Skip to content

Commit 339afba

Browse files
committed
Highlight the unsafe keyword
1 parent 0601540 commit 339afba

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

rust-mode.el

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,11 @@
173173
:safe #'booleanp
174174
:group 'rust-mode)
175175

176+
(defface rust-unsafe-face
177+
'((t :inherit font-lock-warning-face))
178+
"Face for the `unsafe' keyword."
179+
:group 'rust-mode)
180+
176181
(defun rust-paren-level () (nth 0 (syntax-ppss)))
177182
(defun rust-in-str-or-cmnt () (nth 8 (syntax-ppss)))
178183
(defun rust-rewind-past-str-cmnt () (goto-char (nth 8 (syntax-ppss))))
@@ -414,7 +419,7 @@
414419
"ref" "return"
415420
"self" "static" "struct" "super"
416421
"true" "trait" "type"
417-
"unsafe" "use"
422+
"use"
418423
"virtual"
419424
"where" "while"))
420425

@@ -455,6 +460,9 @@
455460
;; Special types
456461
(,(regexp-opt-symbols rust-special-types) . font-lock-type-face)
457462

463+
;; The unsafe keyword
464+
("\\_<unsafe\\_>" . 'rust-unsafe-face)
465+
458466
;; Attributes like `#[bar(baz)]` or `#![bar(baz)]` or `#[bar = "baz"]`
459467
(,(rust-re-grab (concat "#\\!?\\[" rust-re-ident "[^]]*\\]"))
460468
1 font-lock-preprocessor-face keep)

0 commit comments

Comments
 (0)