Skip to content

Consider making compilation-error regexps more permissive. #577

@dabrahams

Description

@dabrahams

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions