Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions rust-mode-tests.el
Original file line number Diff line number Diff line change
Expand Up @@ -1979,6 +1979,28 @@ this_is_not_a_string();)"
"union" font-lock-variable-name-face
"bar" font-lock-type-face)))

(ert-deftest rust-test-raw-context-sensitive ()
(rust-test-font-lock
"let raw = 7; let foo = &raw const raw; let bar = &raw mut raw;"
'("let" font-lock-keyword-face
;; The first raw is a variable name.
"raw" font-lock-variable-name-face
"let" font-lock-keyword-face
"foo" font-lock-variable-name-face
"&" rust-ampersand-face
;; The second raw is a contextual keyword.
"raw" font-lock-keyword-face
"const" font-lock-keyword-face
;; The third raw is a value.
"let" font-lock-keyword-face
"bar" font-lock-variable-name-face
"&" rust-ampersand-face
;; The fourth raw is a contextual keyword.
"raw" font-lock-keyword-face
"mut" font-lock-keyword-face
;; The fifth raw is a value.
)))

(ert-deftest indent-method-chains-no-align ()
(let ((rust-indent-method-chain nil)) (test-indent
"
Expand Down
11 changes: 10 additions & 1 deletion rust-prog-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,14 @@ to the function arguments. When nil, `->' will be indented one level."
(or space line-start)
(group symbol-start "union" symbol-end)
(+ space) (regexp ,rust-re-ident))))
(defconst rust-re-raw
(rx-to-string
`(seq
"&"
(zero-or-more space)
(group "raw")
(one-or-more space)
(or "const" "mut"))))

(defun rust-re-item-def (itype)
(concat (rust-re-word itype)
Expand Down Expand Up @@ -188,7 +196,7 @@ See `prettify-symbols-compose-predicate'."
"let" "loop"
"match" "mod" "move" "mut"
"priv" "pub"
"raw" "ref" "return"
"ref" "return"
"self" "static" "struct" "super"
"true" "trait" "type" "try"
"use"
Expand Down Expand Up @@ -269,6 +277,7 @@ Does not match type annotations of the form \"foo::<\"."
;; Contextual keywords
("\\_<\\(default\\)[[:space:]]+fn\\_>" 1 font-lock-keyword-face)
(,rust-re-union 1 font-lock-keyword-face)
(,rust-re-raw 1 font-lock-keyword-face)

;; Special types
(,(regexp-opt rust-special-types 'symbols) . font-lock-type-face)
Expand Down
Loading