From 00177f542976601d7f114fed82caaa3daad7b177 Mon Sep 17 00:00:00 2001 From: Nathan Moreau Date: Thu, 18 Jun 2020 15:14:48 +0200 Subject: 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) -> u128 { | ------------------------------------------------------- defined here ... 132 | self.total_time_ms = duration_ms_since(&self.program_start, 2); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ --- rust-mode.el | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'rust-mode.el') 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 @@ -1977,6 +1983,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) -- cgit v1.2.3