Skip to content

Commit 8bbe70b

Browse files
authored
Merge pull request #510 from luckysori/match-panics
Match panics in `compilation-mode`
2 parents 9c26dc1 + 3948fae commit 8bbe70b

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

rust-compile.el

+9
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ See `compilation-error-regexp-alist' for help on their format.")
3434
"Specifications for matching code references in rustc invocations.
3535
See `compilation-error-regexp-alist' for help on their format.")
3636

37+
(defvar rustc-panics-compilation-regexps
38+
(let ((re (concat "thread '[^']+' panicked at " rustc-compilation-location)))
39+
(cons re '(2 3 4 nil 1)))
40+
"Specifications for matching panics in rustc invocations.
41+
See `compilation-error-regexp-alist' for help on their format.")
42+
3743
;; Match test run failures and panics during compilation as
3844
;; compilation warnings
3945
(defvar cargo-compilation-regexps
@@ -75,6 +81,9 @@ the compilation window until the top of the error is visible."
7581
(add-to-list 'compilation-error-regexp-alist 'rustc-colon)
7682
(add-to-list 'compilation-error-regexp-alist-alist
7783
(cons 'cargo cargo-compilation-regexps))
84+
(add-to-list 'compilation-error-regexp-alist-alist
85+
(cons 'rustc-panics rustc-panics-compilation-regexps))
86+
(add-to-list 'compilation-error-regexp-alist 'rustc-panics)
7887
(add-to-list 'compilation-error-regexp-alist 'cargo)
7988
(add-hook 'next-error-hook #'rustc-scroll-down-after-next-error)))
8089

rust-mode-tests.el

+5-2
Original file line numberDiff line numberDiff line change
@@ -3600,6 +3600,7 @@ let b = 1;"
36003600
(insert "warning found a -> b\n --> file3.rs:12:34\n\n")
36013601
(insert "note: `ZZZ` could also refer to the constant imported here -> b\n --> file4.rs:12:34\n\n")
36023602
(insert " ::: file5.rs:12:34\n\n")
3603+
(insert "thread 'main' panicked at src/file7.rs:12:34:\n\n")
36033604
;; should not match
36043605
(insert "werror found a -> b\n --> no_match.rs:12:34\n\n")
36053606
(insert "error[E0061]: this function takes 1 parameter but 2 parameters were supplied\n --> file6.rs:132:34
@@ -3618,11 +3619,13 @@ let b = 1;"
36183619
("file6.rs" "132" "34" compilation-error "file6.rs:132:34"))
36193620
(("file5.rs" "12" "34" compilation-info "file5.rs:12:34"))
36203621
((like-previous-one "82" back-to-indentation compilation-info "82")
3621-
(like-previous-one "132" back-to-indentation compilation-info "132")))
3622+
(like-previous-one "132" back-to-indentation compilation-info "132"))
3623+
(("src/file7.rs" "12" "34" nil "src/file7.rs:12:34")))
36223624
(mapcar #'rust-collect-matches
36233625
(list rustc-compilation-regexps
36243626
rustc-colon-compilation-regexps
3625-
rustc-refs-compilation-regexps))))))
3627+
rustc-refs-compilation-regexps
3628+
rustc-panics-compilation-regexps))))))
36263629

36273630
;; If electric-pair-mode is available, load it and run the tests that use it. If not,
36283631
;; no error--the tests will be skipped.

0 commit comments

Comments
 (0)