Skip to content

Commit

Permalink
Merge pull request rust-lang#263 from nikomatsakis/tweak-compilation-…
Browse files Browse the repository at this point in the history
…regexp

remove old-style compilation regex; support `:::` regex
  • Loading branch information
nikomatsakis authored Mar 3, 2018
2 parents cc2435b + 31b8453 commit 42c98bb
Showing 1 changed file with 12 additions and 19 deletions.
31 changes: 12 additions & 19 deletions rust-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -1574,31 +1574,24 @@ This is written mainly to be used as `end-of-defun-function' for Rust."
(defun rust--before-save-hook ()
(when rust-format-on-save (rust-format-buffer)))

;; Issue #6887: Rather than inheriting the 'gnu compilation error
;; regexp (which is broken on a few edge cases), add our own 'rust
;; compilation error regexp and use it instead.
(defvar rustc-compilation-regexps
(let ((file "\\([^\n]+\\)")
(start-line "\\([0-9]+\\)")
(start-col "\\([0-9]+\\)")
(end-line "\\([0-9]+\\)")
(end-col "\\([0-9]+\\)")
(msg-type "\\(?:[Ee]rror\\|\\([Ww]arning\\)\\|\\([Nn]ote\\|[Hh]elp\\)\\)"))
(let ((re (concat "^" file ":" start-line ":" start-col
": " end-line ":" end-col
" " msg-type ":")))
(cons re '(1 (2 . 4) (3 . 5) (6 . 7)))))
(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.
See `compilation-error-regexp-alist' for help on their format.")

(defvar rustc-new-compilation-regexps
(defvar rustc-colon-compilation-regexps
(let ((file "\\([^\n]+\\)")
(start-line "\\([0-9]+\\)")
(start-col "\\([0-9]+\\)"))
(let ((re (concat "^ *--> " file ":" start-line ":" start-col ; --> 1:2:3
(let ((re (concat "^ *::: " file ":" start-line ":" start-col ; ::: foo/bar.rs
)))
(cons re '(1 2 3))))
"Specifications for matching errors in rustc invocations (new style).
"Specifications for matching `:::` hints in rustc invocations.
See `compilation-error-regexp-alist' for help on their format.")

;; Match test run failures and panics during compilation as
Expand Down Expand Up @@ -1630,16 +1623,16 @@ See `compilation-error-regexp-alist' for help on their format.")

(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
(cons 'rustc-colon rustc-colon-compilation-regexps))
(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 'cargo)))
(add-to-list 'compilation-error-regexp-alist 'cargo)
(add-hook 'next-error-hook 'rustc-scroll-down-after-next-error)))

;;; Functions to submit (parts of) buffers to the rust playpen, for
;;; sharing.
Expand Down

0 comments on commit 42c98bb

Please sign in to comment.