[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/rust-mode 00177f5 461/486: compile-mode integration: add l
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/rust-mode 00177f5 461/486: compile-mode integration: add link to code references. (#391) |
Date: |
Sat, 7 Aug 2021 09:26:14 -0400 (EDT) |
branch: elpa/rust-mode
commit 00177f542976601d7f114fed82caaa3daad7b177
Author: Nathan Moreau <nathan.moreau@m4x.org>
Commit: GitHub <noreply@github.com>
compile-mode integration: add link to code references. (#391)
This allows to jump to code references such as lines 82 and 132 in the
following snippet error message.
error[E0061]: this function takes 1 parameter but 2 parameters were supplied
--> file6.rs:132:34
|
82 | fn duration_ms_since(time: &Option<SystemTime>) -> u128 {
| ------------------------------------------------------- defined here
...
132 | self.total_time_ms =
duration_ms_since(&self.program_start, 2);
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
---
rust-mode-tests.el | 41 +++++++++++++++++++++++++++++------------
rust-mode.el | 9 +++++++++
2 files changed, 38 insertions(+), 12 deletions(-)
diff --git a/rust-mode-tests.el b/rust-mode-tests.el
index da874ec..c0e88fa 100644
--- a/rust-mode-tests.el
+++ b/rust-mode-tests.el
@@ -3346,14 +3346,20 @@ impl Two<'a> {
(mapcar (lambda (r)
(let ((match-pos
(nth (cdr r) spec)))
- (if (eq :type (car r))
- (cond ((consp match-pos)
- (compilation-face match-pos))
- (t
- (cdr (assoc match-pos '((1 . compilation-warning)
- (0 . compilation-info)
- (2 .
compilation-error))))))
- (match-string match-pos))))
+ (cond ((and (eq :type (car r)) (consp match-pos))
+ (compilation-face match-pos))
+ ((eq :type (car r))
+ (cdr (assoc match-pos '((1 . compilation-warning)
+ (0 . compilation-info)
+ (2 . compilation-error)))))
+ ((and (null match-pos) (eq :column (car r)))
+ 'back-to-indentation)
+ ((and (null match-pos) (eq :file (car r)))
+ 'like-previous-one)
+ ((null match-pos)
+ (error (format "%S" (car r))))
+ (t
+ (match-string match-pos)))))
;; see compilation-error-regexp-alist
'((:file . 1)
(:line . 2)
@@ -3373,16 +3379,27 @@ impl Two<'a> {
(insert " ::: file5.rs:12:34\n\n")
;; should not match
(insert "werror found a -> b\n --> no_match.rs:12:34\n\n")
-
+ (insert "error[E0061]: this function takes 1 parameter but 2 parameters
were supplied\n --> file6.rs:132:34
+ |
+82 | fn duration_ms_since(time: &Option<SystemTime>) -> u128 {
+ | ------------------------------------------------------- defined here
+...
+132 | self.total_time_ms = duration_ms_since(&self.program_start,
2);
+ |
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+")
(should (equal
'((("file1.rs" "12" "34" compilation-error "file1.rs:12:34")
("file2.rs" "12" "34" compilation-error "file2.rs:12:34")
("file3.rs" "12" "34" compilation-warning "file3.rs:12:34")
- ("file4.rs" "12" "34" compilation-info "file4.rs:12:34"))
- (("file5.rs" "12" "34" compilation-info "file5.rs:12:34")))
+ ("file4.rs" "12" "34" compilation-info "file4.rs:12:34")
+ ("file6.rs" "132" "34" compilation-error "file6.rs:132:34"))
+ (("file5.rs" "12" "34" compilation-info "file5.rs:12:34"))
+ ((like-previous-one "82" back-to-indentation compilation-info
"82")
+ (like-previous-one "132" back-to-indentation compilation-info
"132")))
(mapcar #'rust-collect-matches
(list rustc-compilation-regexps
- rustc-colon-compilation-regexps))))))
+ rustc-colon-compilation-regexps
+ rustc-refs-compilation-regexps))))))
;; If electric-pair-mode is available, load it and run the tests that use it.
If not,
;; no error--the tests will be skipped.
diff --git a/rust-mode.el b/rust-mode.el
index d5e0b93..9711a79 100644
--- a/rust-mode.el
+++ b/rust-mode.el
@@ -1947,6 +1947,12 @@ See `compilation-error-regexp-alist' for help on their
format.")
"Specifications for matching `:::` hints in rustc invocations.
See `compilation-error-regexp-alist' for help on their format.")
+(defvar rustc-refs-compilation-regexps
+ (let ((re "^\\([0-9]+\\)[[:space:]]*|"))
+ (cons re '(nil 1 nil 0 1)))
+ "Specifications for matching code references 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
@@ -1978,6 +1984,9 @@ the compilation window until the top of the error is
visible."
(eval-after-load 'compile
'(progn
(add-to-list 'compilation-error-regexp-alist-alist
+ (cons 'rustc-refs rustc-refs-compilation-regexps))
+ (add-to-list 'compilation-error-regexp-alist 'rustc-refs)
+ (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 6dca073 414/486: readme: make other useful packages a list, (continued)
- [nongnu] elpa/rust-mode 6dca073 414/486: readme: make other useful packages a list, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 7960c74 417/486: Do not allow subword-match when detecting built-in formatting macros, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 5ad9b59 418/486: subword-match for built-in formatting macros: add a test., ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 484d675 419/486: Adding GitHub actions., ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode c5ab165 423/486: mention LSP support, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode a36bc70 426/486: Merge pull request #340 from brotzeit/readme, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 6a57253 427/486: rust-dbg-wrap-or-unwrap: bind to C-c C-d rather than C-c d., ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode e8345f6 440/486: Add triagebot configuration (#364), ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode a364b24 445/486: Make *rustfmt* buffer readonly., ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 15a077a 458/486: rustc-colon-compilation-regexps: improve highlighting., ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 00177f5 461/486: compile-mode integration: add link to code references. (#391),
ELPA Syncer <=
- [nongnu] elpa/rust-mode 5585cf9 477/486: rust-mode: Cosmetics, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 3fa8f0b 479/486: Add non-empty commentary section, slightly reword summary, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 7ff04a8 337/486: Merge pull request #234 from jjwest/master, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 70ff9a0 421/486: electric-pair-mode: prevent self-insert of `>' when already inserted. (#337), ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 4fd637c 428/486: rust-insert-dbg: handle the case of string literals. (#342), ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 844bb51 429/486: add support for "async fn", ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 63ec74c 434/486: Enforce use of spaces for indentation and cleanup whitespace (#353), ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode a36c96a 435/486: integrate rustfmt error messages, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 8665005 436/486: Introduce constant for *rustfmt*., ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 08d7141 449/486: README: support for emacs 24 has been dropped., ELPA Syncer, 2021/08/07