Skip to content

Commit 3220937

Browse files
authored
Merge pull request #209 from tromey/default-keyword
Add support for "default" keyword
2 parents dae5af7 + 758ab8c commit 3220937

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

rust-mode-tests.el

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1510,6 +1510,15 @@ this_is_not_a_string();)"
15101510
;; Only the i32 should have been highlighted.
15111511
'("i32" font-lock-type-face)))
15121512

1513+
(ert-deftest rust-test-default-context-sensitive ()
1514+
(rust-test-font-lock
1515+
"let default = 7; impl foo { default fn f() { } }"
1516+
'("let" font-lock-keyword-face
1517+
"impl" font-lock-keyword-face
1518+
"default" font-lock-keyword-face
1519+
"fn" font-lock-keyword-face
1520+
"f" font-lock-function-name-face)))
1521+
15131522
(ert-deftest indent-method-chains-no-align ()
15141523
(let ((rust-indent-method-chain nil)) (test-indent
15151524
"

rust-mode.el

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,7 @@ buffer."
526526
(defun rust-re-item-def-imenu (itype)
527527
(concat "^[[:space:]]*"
528528
(rust-re-shy (concat (rust-re-word rust-re-vis) "[[:space:]]+")) "?"
529+
(rust-re-shy (concat (rust-re-word "default") "[[:space:]]+")) "?"
529530
(rust-re-shy (concat (rust-re-word rust-re-unsafe) "[[:space:]]+")) "?"
530531
(rust-re-shy (concat (rust-re-word rust-re-extern) "[[:space:]]+"
531532
(rust-re-shy "\"[^\"]+\"[[:space:]]+") "?")) "?"
@@ -555,6 +556,7 @@ the desired identifiers), but does not match type annotations \"foo::<\"."
555556
(append
556557
`(
557558
;; Keywords proper
559+
("\\_<\\(default\\)[[:space:]]+fn\\_>" 1 font-lock-keyword-face)
558560
(,(regexp-opt rust-mode-keywords 'symbols) . font-lock-keyword-face)
559561

560562
;; Special types

0 commit comments

Comments
 (0)