diff options
| author | Nathan Moreau <nathan.moreau@m4x.org> | 2019-10-18 16:24:31 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-10-18 16:24:31 +0200 |
| commit | 7e2533f00e7b8e2f0b1f81a124263fdfb58cdc84 (patch) | |
| tree | f91276d1f43611aabfd1bbb8e5605f0497cef148 | |
| parent | 6dca073b6b59467e661095c5e27ce5827bc36cc7 (diff) | |
| download | rust-mode-7e2533f00e7b8e2f0b1f81a124263fdfb58cdc84.tar.gz | |
Fix rustc-compilation-regexps: match error messages with dashes. (#331)
| -rw-r--r-- | rust-mode-tests.el | 34 | ||||
| -rw-r--r-- | rust-mode.el | 4 |
2 files changed, 36 insertions, 2 deletions
diff --git a/rust-mode-tests.el b/rust-mode-tests.el index a22e43a..ac81d03 100644 --- a/rust-mode-tests.el +++ b/rust-mode-tests.el @@ -3137,6 +3137,40 @@ impl Two<'a> { (let ((default-directory test-dir)) (should (equal (expand-file-name (rust-buffer-project)) manifest-file)))))) +(ert-deftest compilation-regexp-dashes () + (with-temp-buffer + ;; should match + (insert "error found a -> b\n --> file1.rs:12:34\n\n") + (insert "error[E1234]: found a -> b\n --> file2.rs:12:34\n\n") + (insert "warning found a -> b\n --> file3.rs:12:34\n\n") + ;; should not match + (insert "werror found a -> b\n --> file4.rs:12:34\n\n") + + (goto-char (point-min)) + (let ((matches nil)) + (while (re-search-forward (car rustc-compilation-regexps) nil t) + (push + (mapcar (lambda (r) + (let ((match-pos + (nth (cdr r) rustc-compilation-regexps))) + (if (eq :is-warning (car r)) + (compilation-face match-pos) + (match-string match-pos)))) + ;; see compilation-error-regexp-alist + '((:file . 1) + (:line . 2) + (:column . 3) + (:is-warning . 4) + (:mouse-highlight . 5))) + matches)) + (setq matches (reverse matches)) + + (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")) + matches))))) + ;; If electric-pair-mode is available, load it and run the tests that use it. If not, ;; no error--the tests will be skipped. (require 'elec-pair nil t) diff --git a/rust-mode.el b/rust-mode.el index 71e9458..7b14d04 100644 --- a/rust-mode.el +++ b/rust-mode.el @@ -1640,8 +1640,8 @@ Return the created process." (defvar rustc-compilation-regexps (let ((file "\\([^\n]+\\)") (start-line "\\([0-9]+\\)") - (start-col "\\([0-9]+\\)")) - (let ((re (concat "^\\(?:error\\|\\(warning\\)\\)[^-]+--> \\(" file ":" start-line ":" start-col "\\)"))) + (start-col "\\([0-9]+\\)")) + (let ((re (concat "^\\(?:error\\|\\(warning\\)\\)[^\0]+?--> \\(" file ":" start-line ":" start-col "\\)"))) (cons re '(3 4 5 (1) 2)))) "Specifications for matching errors in rustc invocations. See `compilation-error-regexp-alist' for help on their format.") |
