[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/rust-mode e48a650 329/486: Merge pull request #225 from Aa
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/rust-mode e48a650 329/486: Merge pull request #225 from Aankhen/add-var-colours |
Date: |
Sat, 7 Aug 2021 09:25:46 -0400 (EDT) |
branch: elpa/rust-mode
commit e48a650c44c06c1dd4e4ed0672c50c5446124203
Merge: b10ad41 90f70ac
Author: Tom Tromey <tom@tromey.com>
Commit: GitHub <noreply@github.com>
Merge pull request #225 from Aankhen/add-var-colours
Use `font-lock-variable-name-face' for `let' bindings
---
rust-mode-tests.el | 42 +++++++++++++++++++++++++++++++++++++++++-
rust-mode.el | 3 +++
2 files changed, 44 insertions(+), 1 deletion(-)
diff --git a/rust-mode-tests.el b/rust-mode-tests.el
index a9b4af9..7335334 100644
--- a/rust-mode-tests.el
+++ b/rust-mode-tests.el
@@ -1284,12 +1284,46 @@ list of substrings of `STR' each followed by its face."
'("fn" font-lock-keyword-face
"foo_Bar" font-lock-function-name-face)))
+(ert-deftest font-lock-let-bindings ()
+ (rust-test-font-lock
+ "let foo;"
+ '("let" font-lock-keyword-face
+ "foo" font-lock-variable-name-face))
+ (rust-test-font-lock
+ "let mut foo;"
+ '("let" font-lock-keyword-face
+ "mut" font-lock-keyword-face
+ "foo" font-lock-variable-name-face))
+ (rust-test-font-lock
+ "let foo = 1;"
+ '("let" font-lock-keyword-face
+ "foo" font-lock-variable-name-face))
+ (rust-test-font-lock
+ "let mut foo = 1;"
+ '("let" font-lock-keyword-face
+ "mut" font-lock-keyword-face
+ "foo" font-lock-variable-name-face))
+ (rust-test-font-lock
+ "fn foo() { let bar = 1; }"
+ '("fn" font-lock-keyword-face
+ "foo" font-lock-function-name-face
+ "let" font-lock-keyword-face
+ "bar" font-lock-variable-name-face))
+ (rust-test-font-lock
+ "fn foo() { let mut bar = 1; }"
+ '("fn" font-lock-keyword-face
+ "foo" font-lock-function-name-face
+ "let" font-lock-keyword-face
+ "mut" font-lock-keyword-face
+ "bar" font-lock-variable-name-face)))
+
(ert-deftest font-lock-single-quote-character-literal ()
(rust-test-font-lock
"fn main() { let ch = '\\''; }"
'("fn" font-lock-keyword-face
"main" font-lock-function-name-face
"let" font-lock-keyword-face
+ "ch" font-lock-variable-name-face
"'\\''" font-lock-string-face)))
(ert-deftest font-lock-escaped-double-quote-character-literal ()
@@ -1298,6 +1332,7 @@ list of substrings of `STR' each followed by its face."
'("fn" font-lock-keyword-face
"main" font-lock-function-name-face
"let" font-lock-keyword-face
+ "ch" font-lock-variable-name-face
"'\\\"'" font-lock-string-face)))
(ert-deftest font-lock-escaped-backslash-character-literal ()
@@ -1306,18 +1341,21 @@ list of substrings of `STR' each followed by its face."
'("fn" font-lock-keyword-face
"main" font-lock-function-name-face
"let" font-lock-keyword-face
+ "ch" font-lock-variable-name-face
"'\\\\'" font-lock-string-face)))
(ert-deftest font-lock-hex-escape-character-literal ()
(rust-test-font-lock
"let ch = '\\x1f';"
'("let" font-lock-keyword-face
+ "ch" font-lock-variable-name-face
"'\\x1f'" font-lock-string-face)))
(ert-deftest font-lock-unicode-escape-character-literal ()
(rust-test-font-lock
"let ch = '\\u{1ffff}';"
'("let" font-lock-keyword-face
+ "ch" font-lock-variable-name-face
"'\\u{1ffff}'" font-lock-string-face)))
(ert-deftest font-lock-raw-strings-no-hashes ()
@@ -1583,6 +1621,7 @@ this_is_not_a_string();)"
(rust-test-font-lock
"let default = 7; impl foo { default fn f() { } }"
'("let" font-lock-keyword-face
+ "default" font-lock-variable-name-face
"impl" font-lock-keyword-face
"default" font-lock-keyword-face
"fn" font-lock-keyword-face
@@ -1592,7 +1631,8 @@ this_is_not_a_string();)"
(rust-test-font-lock
"let union = 7; union foo { x: &'union bar }"
'("let" font-lock-keyword-face
- ;; Ignore the first union, it's an unhighlighted variable.
+ ;; The first union is a variable name.
+ "union" font-lock-variable-name-face
;; The second union is a contextual keyword.
"union" font-lock-keyword-face
"foo" font-lock-type-face
diff --git a/rust-mode.el b/rust-mode.el
index 3b2a856..1c0921b 100644
--- a/rust-mode.el
+++ b/rust-mode.el
@@ -681,6 +681,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)
+ ;; Type-inferred binding
+ (,(concat "\\_<\\(?:let\\|ref\\)\\s-+\\(?:mut\\s-+\\)?" (rust-re-grab
rust-re-ident) "\\_>") 1 font-lock-variable-name-face)
+
;; Type names like `Foo::`, highlight excluding the ::
(,(rust-path-font-lock-matcher rust-re-uc-ident) 1 font-lock-type-face)
- [nongnu] elpa/rust-mode 610fe1f 305/486: Address review comments, (continued)
- [nongnu] elpa/rust-mode 610fe1f 305/486: Address review comments, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 72c479b 311/486: Add `rust-run-clippy' and `rust-buffer-project' with testing paraphernalia., ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 4ec735e 300/486: Add stderr output from rustfmt on exit code 3, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 9afe997 313/486: Declare `rust-buffer-project' and require `json' at runtime., ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode b4077f8 314/486: Add `rust-cargo-bin' custom variable., ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode d2bb17c 315/486: Skip `rust-test-project-located' without cargo and avoid `find-file' in test., ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 0985f5f 318/486: Merge pull request #217 from Aankhen/add-clippy-command, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 34cc528 319/486: Highlight question mark operator using new `rust-question-mark-face'., ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 2a9fcd0 321/486: Add syntax highlighting and imenu support for `union`, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 89320ad 323/486: Highlight interpolation in arguments to print! &c., ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode e48a650 329/486: Merge pull request #225 from Aankhen/add-var-colours,
ELPA Syncer <=
- [nongnu] elpa/rust-mode 6e9db46 331/486: Merge pull request #230 from tromey/fix-indentation-bug, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 0e832ec 340/486: Remove `float`, `int`, and `uint` as built-in types., ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 302b537 344/486: Revert #216 and Add Suggestions from #226, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode b8e4908 345/486: Merge pull request #243 from iwillspeak/rust-compile-command, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 6bcb82b 350/486: Merge pull request #249 from brotzeit/rust--format-call, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 705f3e4 352/486: Improved font-locking for print macros, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 2fe1f9d 355/486: add dyn to keywords, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 0d408d5 357/486: Merge pull request #253 from jjwest/master, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 42c98bb 362/486: Merge pull request #263 from nikomatsakis/tweak-compilation-regexp, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 3613551 365/486: throw error in after-save-hook instead of before-save-hook, ELPA Syncer, 2021/08/07