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

From: Mattias Engdegård <[email-masked]>
Date: Fri, 31 May 2024 19:15:52 +0200

Ergus, thank you for your contribution! Some questions, if you don't mind:

* There aren't any tests. If you care anything at all about your pattern working, and keep working, you should add some.

We'll help you out, of course, but it's probably best if you give it a go yourself first so that we know exactly what you want to match. Take a look at compile-tests.el, `compile-tests--test-regexps-data`. You will also need to increase the expected counts at the end of `compile-test-error-regexps`.

* The regexp doesn't match the variant with error code inside square brackets, the

error[E0425]: cannot find function `ruun` in module `broot::cli`

kind of message. Surely you intended it to?

Here is your regexp again, translated to rx and with line numbers for ease of discussion:

1 (rx (| (group-n 4 "error") (group-n 5 "warning"))
2     ":"
3     (+? (not (in "\x00")))
4     "--> "
5     (group-n 1 (+ (not (in ":"))))
6     ":"
7     (group-n 2 (+ digit))
8     ":"
9     (group-n 3 (+ digit)))

* (Line 1): From the examples it appears that the messages start at the beginning of a line. We very much prefer to anchor matches for reasons of performance and to avoid collisions with other patterns. How about we add a line-start anchor at the very beginning?

* (Line 3): This is an open-ended expression which will merrily match just about anything including newlines. This can become very expensive. And where does that NUL come from?

In the examples you supplied, the message is on the first line, and the " --> " on the start of the second. Can we rely on that? If not, what can we rely on?

* (Line 5): This excludes Windows file names which can include colon or do cargo messages have a special notation for those? In any case, it's usually a good idea to exclude newline as well to prevent a runaway repetition.

* Both the rust-mode and rustic packages appear to include regexps that match the same messages. How do they compare to yours?

What is the effect of someone using those modes with your regexp in Emacs?