summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--rust-mode-tests.el14
-rw-r--r--rust-mode.el6
2 files changed, 19 insertions, 1 deletions
diff --git a/rust-mode-tests.el b/rust-mode-tests.el
index 64d65c4..9d87960 100644
--- a/rust-mode-tests.el
+++ b/rust-mode-tests.el
@@ -3061,6 +3061,20 @@ extern \"rust-intrinsic\" fn five() {
"four"
"five"))))
+(ert-deftest rust-test-imenu-impl-with-lifetime ()
+ (test-imenu
+ "
+impl<'a> One<'a> {
+ fn one() {}
+}
+
+impl Two<'a> {
+ fn two() {}
+}
+"
+ '(("Impl" "One" "Two")
+ ("Fn" "one" "two"))))
+
(when (executable-find rust-cargo-bin)
(ert-deftest rust-test-project-located ()
(lexical-let* ((test-dir (expand-file-name "test-project" default-directory))
diff --git a/rust-mode.el b/rust-mode.el
index 8af6610..a8af671 100644
--- a/rust-mode.el
+++ b/rust-mode.el
@@ -39,6 +39,8 @@
(defconst rust-re-vis "pub")
(defconst rust-re-unsafe "unsafe")
(defconst rust-re-extern "extern")
+(defconst rust-re-generic
+ (concat "<[[:space:]]*'" rust-re-ident "[[:space:]]*>"))
(defconst rust-re-union
(rx-to-string
`(seq
@@ -561,7 +563,9 @@ buffer."
(defun rust-re-grab (inner) (concat "\\(" inner "\\)"))
(defun rust-re-shy (inner) (concat "\\(?:" inner "\\)"))
(defun rust-re-item-def (itype)
- (concat (rust-re-word itype) "[[:space:]]+" (rust-re-grab rust-re-ident)))
+ (concat (rust-re-word itype)
+ (rust-re-shy rust-re-generic) "?"
+ "[[:space:]]+" (rust-re-grab rust-re-ident)))
(defun rust-re-item-def-imenu (itype)
(concat "^[[:space:]]*"
(rust-re-shy (concat (rust-re-word rust-re-vis) "[[:space:]]+")) "?"