diff options
| author | Nathan Moreau <nathan.moreau@m4x.org> | 2018-12-18 02:40:50 +0100 |
|---|---|---|
| committer | Nathan Moreau <nathan.moreau@m4x.org> | 2018-12-18 03:04:39 +0100 |
| commit | b44573743ed9146aea0470910ee073792ab46e66 (patch) | |
| tree | d298fed06b6ac2aaf643f6ec8560106e926eec27 | |
| parent | 12cb16964ce01f0e484b082ccc8a3430cc1c4158 (diff) | |
| download | rust-mode-b44573743ed9146aea0470910ee073792ab46e66.tar.gz | |
imenu: handle lifetimes in impl blocks.
| -rw-r--r-- | rust-mode-tests.el | 14 | ||||
| -rw-r--r-- | rust-mode.el | 6 |
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:]]+")) "?" |
