From dd6d417c1404efcf2364a61fd7e855ec134a991f Mon Sep 17 00:00:00 2001 From: Wilfred Hughes Date: Wed, 30 Dec 2015 11:24:35 +0000 Subject: Fix type annotations incorrectly highlighted as modules. Previously, we were always treating :: as a module, but Rust allows type annotations using :: e.g. parse::(); This also changes module highlighting so that only the module name is highlighted, excluding the ::. This makes rust-mode consistent with other Emacs modes, such as c++-mode and ruby-mode. --- rust-mode-tests.el | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'rust-mode-tests.el') diff --git a/rust-mode-tests.el b/rust-mode-tests.el index e7a0429..e41245f 100644 --- a/rust-mode-tests.el +++ b/rust-mode-tests.el @@ -1403,6 +1403,27 @@ this_is_not_a_string();)" "\"/*! doc */\"" '("\"/*! doc */\"" font-lock-string-face))) +(ert-deftest font-lock-module () + (rust-test-font-lock + "foo::bar" + '("foo" font-lock-type-face))) + +(ert-deftest font-lock-submodule () + (rust-test-font-lock + "foo::bar::baz" + '("foo" font-lock-type-face + "bar" font-lock-type-face))) + +(ert-deftest font-lock-type-annotation () + "Ensure type annotations are not confused with modules." + (rust-test-font-lock + "parse::();" + ;; Only the i32 should have been highlighted. + '("i32" font-lock-type-face)) + (rust-test-font-lock + "foo:: " + ;; Only the i32 should have been highlighted. + '("i32" font-lock-type-face))) (ert-deftest indent-method-chains-no-align () (let ((rust-indent-method-chain nil)) (test-indent -- cgit v1.2.3