[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/rust-mode 40c33fd 250/486: add code to handle new-style ru
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/rust-mode 40c33fd 250/486: add code to handle new-style rustc errors |
Date: |
Sat, 7 Aug 2021 09:25:29 -0400 (EDT) |
branch: elpa/rust-mode
commit 40c33fd71d87e10776d86f15f35c4fb2a2202879
Author: Niko Matsakis <niko@alum.mit.edu>
Commit: Niko Matsakis <niko@alum.mit.edu>
add code to handle new-style rustc errors
These errors are available on nightly builds (or will be soon), but
only (at the moment) when enabled via environment variable. They will
become the default at some point in the future.
In this commit we match on the `-->`, but after that we have to scroll
the compilation window to make the error visible. One shortcoming is
that if you enter the window and click on the filename/line-number, then
the "next-error-hook" doesn't seem to run. (If you click at the start of
the line, it does.) It may be possible to tweak the "hyperlink" here to
make that work more smoothly, or perhaps add a hook somewhere else.
---
rust-mode.el | 34 ++++++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
diff --git a/rust-mode.el b/rust-mode.el
index df7e93c..b0f8379 100644
--- a/rust-mode.el
+++ b/rust-mode.el
@@ -1381,6 +1381,16 @@ This is written mainly to be used as
`end-of-defun-function' for Rust."
"Specifications for matching errors in rustc invocations.
See `compilation-error-regexp-alist' for help on their format.")
+(defvar rustc-new-compilation-regexps
+ (let ((file "\\([^\n]+\\)")
+ (start-line "\\([0-9]+\\)")
+ (start-col "\\([0-9]+\\)"))
+ (let ((re (concat "^ *--> " file ":" start-line ":" start-col ; --> 1:2:3
+ )))
+ (cons re '(1 2 3))))
+ "Specifications for matching errors in rustc invocations (new style).
+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
@@ -1388,9 +1398,33 @@ See `compilation-error-regexp-alist' for help on their
format.")
"Specifications for matching panics in cargo test invocations.
See `compilation-error-regexp-alist' for help on their format.")
+(defun rustc-scroll-down-after-next-error ()
+ "In the new style error messages, the regular expression
+ matches on the file name (which appears after `-->`), but the
+ start of the error appears a few lines earlier. This hook runs
+ after `M-x next-error`; it simply scrolls down a few lines in
+ the compilation window until the top of the error is visible."
+ (save-selected-window
+ (when (eq major-mode 'rust-mode)
+ (select-window (get-buffer-window next-error-last-buffer))
+ (when (save-excursion
+ (beginning-of-line)
+ (looking-at " *-->"))
+ (let ((start-of-error
+ (save-excursion
+ (beginning-of-line)
+ (while (not (looking-at "^[a-z]+:"))
+ (forward-line -1))
+ (point))))
+ (set-window-start (selected-window) start-of-error))))))
+
(eval-after-load 'compile
'(progn
(add-to-list 'compilation-error-regexp-alist-alist
+ (cons 'rustc-new rustc-new-compilation-regexps))
+ (add-to-list 'compilation-error-regexp-alist 'rustc-new)
+ (add-hook 'next-error-hook 'rustc-scroll-down-after-next-error)
+ (add-to-list 'compilation-error-regexp-alist-alist
(cons 'rustc rustc-compilation-regexps))
(add-to-list 'compilation-error-regexp-alist 'rustc)
(add-to-list 'compilation-error-regexp-alist-alist
- [nongnu] elpa/rust-mode f2f4d67 158/486: Merge pull request #59 from lunaryorn/fix-byte-compiler-warnings, (continued)
- [nongnu] elpa/rust-mode f2f4d67 158/486: Merge pull request #59 from lunaryorn/fix-byte-compiler-warnings, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode ddf45ed 146/486: Use (goto-char (point-max)) instead of (end-of-buffer) to silence warning., ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 0077bbf 160/486: Fix package.el URL, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 86db9bd 166/486: Merge pull request #65 from tromey/blink-matching-paren, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 53c558c 175/486: Factor out rust-conditional-re-search-forward, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 5231709 177/486: Speed up calls to "looking-back", ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode c801dda 197/486: Merge pull request #77 from tromey/fix-byte-compiler-add-lexbind, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode cdaf3fc 201/486: Update MELPA URL, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 1761a9c 204/486: Merge pull request #105 from MicahChalmer/remove-misc, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode f8d94cb 229/486: Use catch and throw instead of block and return, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 40c33fd 250/486: add code to handle new-style rustc errors,
ELPA Syncer <=
- [nongnu] elpa/rust-mode c69adaf 254/486: Add menu titles for items in imenu, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode dae5af7 298/486: Merge pull request #198 from tromey/indentation-fix, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode bfe4056 452/486: Re-implement rust-in-macro for performance, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode eaf95af 210/486: Merge pull request #111 from mrBliss/where-indentation, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 2540d7e 262/486: Go back to the current line and column after formatting., ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 52870b6 203/486: Remove unused require of misc.el, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 95d089c 211/486: Merge pull request #110 from mrBliss/fix-103, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 00e5366 224/486: Merge pull request #122 from kraai/remove-duplicate-keywords, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 0601540 205/486: Merge pull request #96 from MicahChalmer/add-licenses, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 1492106 232/486: Fix hook args for after-revert-hook, ELPA Syncer, 2021/08/07