Skip to content

Commit 7ff04a8

Browse files
authored
Merge pull request #234 from jjwest/master
Types get correct font-lock in if-let statements
2 parents f57a8eb + 6550d94 commit 7ff04a8

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

rust-mode-tests.el

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1317,6 +1317,15 @@ list of substrings of `STR' each followed by its face."
13171317
"mut" font-lock-keyword-face
13181318
"bar" font-lock-variable-name-face)))
13191319

1320+
(ert-deftest font-lock-if-let-binding ()
1321+
(rust-test-font-lock
1322+
"if let Some(var) = some_var { /* no-op */ }"
1323+
'("if" font-lock-keyword-face
1324+
"let" font-lock-keyword-face
1325+
"Some" font-lock-type-face
1326+
"/* " font-lock-comment-delimiter-face
1327+
"no-op */" font-lock-comment-face)))
1328+
13201329
(ert-deftest font-lock-single-quote-character-literal ()
13211330
(rust-test-font-lock
13221331
"fn main() { let ch = '\\''; }"

rust-mode.el

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -682,6 +682,9 @@ match data if found. Returns nil if not within a Rust string."
682682
;; Field names like `foo:`, highlight excluding the :
683683
(,(concat (rust-re-grab rust-re-ident) ":[^:]") 1 font-lock-variable-name-face)
684684

685+
;; CamelCase Means Type Or Constructor
686+
(,rust-re-type-or-constructor 1 font-lock-type-face)
687+
685688
;; Type-inferred binding
686689
(,(concat "\\_<\\(?:let\\|ref\\)\\s-+\\(?:mut\\s-+\\)?" (rust-re-grab rust-re-ident) "\\_>") 1 font-lock-variable-name-face)
687690

@@ -694,9 +697,6 @@ match data if found. Returns nil if not within a Rust string."
694697
;; Lifetimes like `'foo`
695698
(,(concat "'" (rust-re-grab rust-re-ident) "[^']") 1 font-lock-variable-name-face)
696699

697-
;; CamelCase Means Type Or Constructor
698-
(,rust-re-type-or-constructor 1 font-lock-type-face)
699-
700700
;; Question mark operator
701701
("\\?" . 'rust-question-mark-face)
702702
)

0 commit comments

Comments
 (0)