summaryrefslogtreecommitdiff
path: root/rust-mode-tests.el
diff options
context:
space:
mode:
authorWilfred Hughes <me@wilfred.me.uk>2017-07-30 23:13:09 +0100
committerWilfred Hughes <me@wilfred.me.uk>2017-07-30 23:31:01 +0100
commit2a9fcd033b18bec27bbdeecc1397f2ddf4092bb1 (patch)
tree87169c668cc8b1d88f7299052cefea15093cd528 /rust-mode-tests.el
parent09efc45dee786cb220c233426ddd82b26ad950eb (diff)
downloadrust-mode-2a9fcd033b18bec27bbdeecc1397f2ddf4092bb1.tar.gz
Add syntax highlighting and imenu support for `union`
`union` is a contextual keyword, so highlight it in the correct context. Otherwise, treat `union` similarly to `struct`.
Diffstat (limited to 'rust-mode-tests.el')
-rw-r--r--rust-mode-tests.el13
1 files changed, 13 insertions, 0 deletions
diff --git a/rust-mode-tests.el b/rust-mode-tests.el
index 614340c..7f1020f 100644
--- a/rust-mode-tests.el
+++ b/rust-mode-tests.el
@@ -1551,6 +1551,19 @@ this_is_not_a_string();)"
"fn" font-lock-keyword-face
"f" font-lock-function-name-face)))
+(ert-deftest rust-test-union-context-sensitive ()
+ (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 second union is a contextual keyword.
+ "union" font-lock-keyword-face
+ "foo" font-lock-type-face
+ "x" font-lock-variable-name-face
+ ;; This union is the name of a lifetime.
+ "union" font-lock-variable-name-face
+ "bar" font-lock-type-face)))
+
(ert-deftest indent-method-chains-no-align ()
(let ((rust-indent-method-chain nil)) (test-indent
"