branch: elpa/rust-mode
commit 7ff04a8d26104c2e2c0737e219b320ecaeaafd9d
Merge: f57a8eb 6550d94
Author: Tom Tromey <[email protected]>
Commit: GitHub <[email protected]>
Merge pull request #234 from jjwest/master
Types get correct font-lock in if-let statements
---
rust-mode-tests.el | 9 +++++++++
rust-mode.el | 6 +++---
2 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/rust-mode-tests.el b/rust-mode-tests.el
index aab82df..f0a73a2 100644
--- a/rust-mode-tests.el
+++ b/rust-mode-tests.el
@@ -1317,6 +1317,15 @@ list of substrings of `STR' each followed by its face."
"mut" font-lock-keyword-face
"bar" font-lock-variable-name-face)))
+(ert-deftest font-lock-if-let-binding ()
+ (rust-test-font-lock
+ "if let Some(var) = some_var { /* no-op */ }"
+ '("if" font-lock-keyword-face
+ "let" font-lock-keyword-face
+ "Some" font-lock-type-face
+ "/* " font-lock-comment-delimiter-face
+ "no-op */" font-lock-comment-face)))
+
(ert-deftest font-lock-single-quote-character-literal ()
(rust-test-font-lock
"fn main() { let ch = '\\''; }"
diff --git a/rust-mode.el b/rust-mode.el
index 97b5c3c..72109e5 100644
--- a/rust-mode.el
+++ b/rust-mode.el
@@ -682,6 +682,9 @@ match data if found. Returns nil if not within a Rust
string."
;; Field names like `foo:`, highlight excluding the :
(,(concat (rust-re-grab rust-re-ident) ":[^:]") 1
font-lock-variable-name-face)
+ ;; CamelCase Means Type Or Constructor
+ (,rust-re-type-or-constructor 1 font-lock-type-face)
+
;; Type-inferred binding
(,(concat "\\_<\\(?:let\\|ref\\)\\s-+\\(?:mut\\s-+\\)?" (rust-re-grab
rust-re-ident) "\\_>") 1 font-lock-variable-name-face)
@@ -694,9 +697,6 @@ match data if found. Returns nil if not within a Rust
string."
;; Lifetimes like `'foo`
(,(concat "'" (rust-re-grab rust-re-ident) "[^']") 1
font-lock-variable-name-face)
- ;; CamelCase Means Type Or Constructor
- (,rust-re-type-or-constructor 1 font-lock-type-face)
-
;; Question mark operator
("\\?" . 'rust-question-mark-face)
)