Skip to content

Commit 061e6d8

Browse files
committed
Merge pull request #109 from mrBliss/highlight-unsafe
Highlight the unsafe keyword
2 parents b874bbe + 339afba commit 061e6d8

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
@@ -180,6 +180,11 @@ function or trait. When nil, where will be aligned with fn or trait."
180180
:safe #'booleanp
181181
:group 'rust-mode)
182182

183+
(defface rust-unsafe-face
184+
'((t :inherit font-lock-warning-face))
185+
"Face for the `unsafe' keyword."
186+
:group 'rust-mode)
187+
183188
(defun rust-paren-level () (nth 0 (syntax-ppss)))
184189
(defun rust-in-str-or-cmnt () (nth 8 (syntax-ppss)))
185190
(defun rust-rewind-past-str-cmnt () (goto-char (nth 8 (syntax-ppss))))
@@ -488,7 +493,7 @@ function or trait. When nil, where will be aligned with fn or trait."
488493
"ref" "return"
489494
"self" "static" "struct" "super"
490495
"true" "trait" "type"
491-
"unsafe" "use"
496+
"use"
492497
"virtual"
493498
"where" "while"))
494499

@@ -529,6 +534,9 @@ function or trait. When nil, where will be aligned with fn or trait."
529534
;; Special types
530535
(,(regexp-opt-symbols rust-special-types) . font-lock-type-face)
531536

537+
;; The unsafe keyword
538+
("\\_<unsafe\\_>" . 'rust-unsafe-face)
539+
532540
;; Attributes like `#[bar(baz)]` or `#![bar(baz)]` or `#[bar = "baz"]`
533541
(,(rust-re-grab (concat "#\\!?\\[" rust-re-ident "[^]]*\\]"))
534542
1 font-lock-preprocessor-face keep)

0 commit comments

Comments
 (0)