File tree Expand file tree Collapse file tree 2 files changed +43
-0
lines changed Expand file tree Collapse file tree 2 files changed +43
-0
lines changed Original file line number Diff line number Diff line change 3
3
(require 'rust-mode )
4
4
(require 'ert )
5
5
(require 'cl )
6
+ (require 'imenu )
6
7
7
8
(setq rust-test-fill-column 32 )
8
9
@@ -2614,6 +2615,45 @@ Fontification needs to include this whole string or none of it.
2614
2615
(rust--after-revert-hook)
2615
2616
(should (equal initial-point (point ))))))
2616
2617
2618
+ (defun test-imenu (code expected-items )
2619
+ (with-temp-buffer
2620
+ (rust-mode )
2621
+ (insert code)
2622
+ (let ((actual-items
2623
+ ; ; Replace ("item" . #<marker at ? in ?.rs) with "item"
2624
+ (mapcar (lambda (class )
2625
+ (cons (car class)
2626
+ (mapcar #'car (cdr class))))
2627
+ (imenu--generic-function rust-imenu-generic-expression))))
2628
+ (should (equal expected-items actual-items)))))
2629
+
2630
+ (ert-deftest rust-test-imenu-extern-unsafe-fn ()
2631
+ (test-imenu
2632
+ "
2633
+ fn one() {
2634
+ }
2635
+
2636
+ unsafe fn two() {
2637
+ }
2638
+
2639
+ extern \" C\" fn three() {
2640
+ }
2641
+
2642
+ pub extern fn four() {
2643
+
2644
+ }
2645
+
2646
+ extern \" rust-intrinsic\" fn five() {
2647
+
2648
+ }
2649
+ "
2650
+ '((" Fn"
2651
+ " one"
2652
+ " two"
2653
+ " three"
2654
+ " four"
2655
+ " five" ))))
2656
+
2617
2657
; ; If electric-pair-mode is available, load it and run the tests that use it. If not,
2618
2658
; ; no error--the tests will be skipped.
2619
2659
(require 'elec-pair nil t )
Original file line number Diff line number Diff line change 33
33
(defconst rust-re-uc-ident " [[:upper:]][[:word:][:multibyte:]_[:digit:]]*" )
34
34
(defconst rust-re-vis " pub" )
35
35
(defconst rust-re-unsafe " unsafe" )
36
+ (defconst rust-re-extern " extern" )
36
37
37
38
(defconst rust-re-non-standard-string
38
39
(rx
@@ -571,6 +572,8 @@ buffer."
571
572
(concat " ^[[:space:]]*"
572
573
(rust-re-shy (concat (rust-re-word rust-re-vis) " [[:space:]]+" )) " ?"
573
574
(rust-re-shy (concat (rust-re-word rust-re-unsafe) " [[:space:]]+" )) " ?"
575
+ (rust-re-shy (concat (rust-re-word rust-re-extern) " [[:space:]]+"
576
+ (rust-re-shy " \" [^\" ]+\" [[:space:]]+" ) " ?" )) " ?"
574
577
(rust-re-item-def itype)))
575
578
576
579
(defconst rust-re-special-types (regexp-opt rust-special-types 'symbols ))
You can’t perform that action at this time.
0 commit comments