emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/rust-mode 897af24 410/486: rust-mode.el: check for possibl


From: ELPA Syncer
Subject: [nongnu] elpa/rust-mode 897af24 410/486: rust-mode.el: check for possible space between variable name and type (#325)
Date: Sat, 7 Aug 2021 09:26:03 -0400 (EDT)

branch: elpa/rust-mode
commit 897af2444c0f7d8e7059632977402022c9b00ed9
Author: Konstantin Kharlamov <Hi-Angel@users.noreply.github.com>
Commit: Nathan Moreau <nathan.moreau@m4x.org>

    rust-mode.el: check for possible space between variable name and type (#325)
    
    Fixes the following problem: consider code
    
        fn foo(a: u32, b : u32) {}
    
    Here, `b` was not highlighted as a variable, because the regex didn't
    take into account possible space before the colon.
    
    Signed-off-by: Konstantin Kharlamov <Hi-Angel@yandex.ru>
---
 rust-mode-tests.el | 10 ++++++++++
 rust-mode.el       |  2 +-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/rust-mode-tests.el b/rust-mode-tests.el
index b13c1ba..0c1ad1d 100644
--- a/rust-mode-tests.el
+++ b/rust-mode-tests.el
@@ -3108,6 +3108,16 @@ impl Two<'a> {
    '(("Impl" "One" "Two")
      ("Fn" "one" "two"))))
 
+(ert-deftest font-lock-function-parameters ()
+  (rust-test-font-lock
+   "fn foo(a: u32, b : u32) {}"
+   '("fn" font-lock-keyword-face
+     "foo" font-lock-function-name-face
+     "a" font-lock-variable-name-face
+     "u32" font-lock-type-face
+     "b" font-lock-variable-name-face
+     "u32" font-lock-type-face)))
+
 (when (executable-find rust-cargo-bin)
   (ert-deftest rust-test-project-located ()
     (lexical-let* ((test-dir (expand-file-name "test-project" 
default-directory))
diff --git a/rust-mode.el b/rust-mode.el
index e57a650..cdc44e5 100644
--- a/rust-mode.el
+++ b/rust-mode.el
@@ -694,7 +694,7 @@ Returns nil if the point is not within a Rust string."
       1 font-lock-preprocessor-face)
 
      ;; Field names like `foo:`, highlight excluding the :
-     (,(concat (rust-re-grab rust-re-ident) ":[^:]") 1 
font-lock-variable-name-face)
+     (,(concat (rust-re-grab rust-re-ident) "[[:space:]]*:[^:]") 1 
font-lock-variable-name-face)
 
      ;; CamelCase Means Type Or Constructor
      (,rust-re-type-or-constructor 1 font-lock-type-face)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]