rust-lang / rust-lang/rust-mode
Consider making compilation-error regexps more permissive.
Nobody has claimed this yet.
- Dominant language
- Emacs Lisp
- Stars
- 1.3k
- Forks
- 198
- PR merge metrics
- No merged PRs in 30d
Description
It is an unfortunate reality that other tools that invoke cargo or rustc will add prefix text to its diagnostics, which breaks compilation-mode. Consider removing the beginning of line anchor from these regexps. See also #576.
I'm currently doing this to work around it,
(defun dwa/dioxus-rust-compilation-error-patch ()
"Update the rust error message formats to account for https://github.com/DioxusLabs/dioxus/issues/4547."
;; Look for all potential rust errors
(dolist (key '(rustc-panics cargo rustc-colon rustc rustc-refs) nil)
(let* ((e (cdr (assoc key compilation-error-regexp-alist-alist)))
(pattern (car e))
(prefix "^\\(?: +[0-9]+[.] ?[0-9]*s +INFO +\\)?"))
(when
(and pattern
;; Anything not anchored at the beginning of the line
;; should match without changes.
(string-prefix-p "^" pattern)
;; Attempt to make this modification idempotent
(not (string-prefix-p prefix pattern)))
;; Shadow the existing alist entry; no need to modify it.
(add-to-list
'compilation-error-regexp-alist-alist
;; Inject the prefix after the "^"
`(,key . ,(cons (concat prefix (substring pattern 1)) (cdr e))))))))
But I also need to redefine rustc-scroll-down-after-next-error because it also embeds an anchor in a literal string.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Search the compilation-error-regexp-alist-alist entries for rustc-panics, cargo, rustc-colon, rustc, and rustc-refs, then inspect rustc-scroll-down-after-next-error. Verify how the anchored patterns handle prefixed cargo or rustc diagnostics; done means compilation-mode recognizes those errors and scrolling remains consistent.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- emacs, emacs-lisp, rust
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100