Subject: bug#70794: 30.0.50; Add Rust compilation regex

From: Mattias Engdegård <[email-masked]>
Date: Thu, 15 May 2025 20:42:42 +0200

28 apr. 2025 kl. 22.22 skrev Vincenzo Pupillo <[email-masked]>:

> diff --git a/lisp/progmodes/compile.el b/lisp/progmodes/compile.el
> index 1ca58b3ac7d..7a1b5d4fdd1 100644
> --- a/lisp/progmodes/compile.el
> +++ b/lisp/progmodes/compile.el
> @@ -565,6 +565,13 @@ compilation-error-regexp-alist-alist
>       "\\(?:Parse\\|Fatal\\) error: \\(.*\\) in \\(.*\\) on line \\([0-9]+\\)"
>       2 3 nil nil)
>  
> +    (rustc-error

Can't you combine the error and warning patterns into a single rule? It's what we normally try to do, and it doesn't make much sense having one without the other. The rust-mode code seems to indicate that there are info-level messages (using 'note:') so let's include those as well.

> +     "^error[^:]*:[^\n]*\n\s+-->\s\\([^\n]+\\):\\([0-9]+\\):\\([0-9]+\\)"

"[^\n]" is usually written as "." (in rx it's `not-newline` or `nonl`).

As mentioned before, the "[^:]*" matches way too much.

It seems that the number of spaces before the arrow is hard-coded to 2 in the output.

The "[^\n]+" for matching the file name will match all the way to the end, then backtrack several times to the first colon. But maybe you wrote it that way for Windows file names containing a drive letter? In that case we have little choice.

What about the following then:

 (rx bol (or "error" (group-n 1 "warning") (group-n 2 "note"))
     (? "[" (+ (in "A-Z" "0-9")) "]") ":" (* nonl)
     "\n  --> " (group-n 3 (+ nonl))   ; file
     ":" (group-n 4 (+ (in "0-9")))    ; line
     ":" (group-n 5 (+ (in "0-9"))))   ; column

If you like this, then please also include an example for 'note' messages, and add one to the tests.