diff options
| author | Lucas Soriano del Pino <lucas_soriano@fastmail.com> | 2024-02-11 11:54:31 +1100 |
|---|---|---|
| committer | Lucas Soriano del Pino <lucas_soriano@fastmail.com> | 2024-02-13 13:07:21 +1100 |
| commit | 3948faec12f72b0b11fd573e3bcfe323de5b6d80 (patch) | |
| tree | 9393ae1074271d93c396848348e68869fb1dbe55 /rust-compile.el | |
| parent | 9c26dc1195ec05309ee15c014631fb9abd6cf5d2 (diff) | |
| download | rust-mode-3948faec12f72b0b11fd573e3bcfe323de5b6d80.tar.gz | |
Match panics in compilation-mode
If we encounter a panic when executing Rust code in
`compilation-mode`, we now correctly highlight the location where the
panic occurred.
For example:
```
thread 'main' panicked at src/main.rs:2:5:
explicit panic
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
```
Here, `src/main.rs:2:5` is highlighted. The developer is then able to
execute `compile-goto-error` to jump to the correct spot in the code.
Co-authored-by: Brent Westbrook <brentrwestbrook@gmail.com>
Co-authored-by: zlef <zachlefevre@gmail.com>
Diffstat (limited to 'rust-compile.el')
| -rw-r--r-- | rust-compile.el | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/rust-compile.el b/rust-compile.el index 1bb3103..04ac6b6 100644 --- a/rust-compile.el +++ b/rust-compile.el @@ -34,6 +34,12 @@ See `compilation-error-regexp-alist' for help on their format.") "Specifications for matching code references in rustc invocations. See `compilation-error-regexp-alist' for help on their format.") +(defvar rustc-panics-compilation-regexps + (let ((re (concat "thread '[^']+' panicked at " rustc-compilation-location))) + (cons re '(2 3 4 nil 1))) + "Specifications for matching panics in rustc invocations. +See `compilation-error-regexp-alist' for help on their format.") + ;; Match test run failures and panics during compilation as ;; compilation warnings (defvar cargo-compilation-regexps @@ -75,6 +81,9 @@ the compilation window until the top of the error is visible." (add-to-list 'compilation-error-regexp-alist 'rustc-colon) (add-to-list 'compilation-error-regexp-alist-alist (cons 'cargo cargo-compilation-regexps)) + (add-to-list 'compilation-error-regexp-alist-alist + (cons 'rustc-panics rustc-panics-compilation-regexps)) + (add-to-list 'compilation-error-regexp-alist 'rustc-panics) (add-to-list 'compilation-error-regexp-alist 'cargo) (add-hook 'next-error-hook #'rustc-scroll-down-after-next-error))) |
