GNU bug report logs - #70794
30.0.50; Add Rust compilation regex

Previous Next

Package: emacs;

Reported by: Ergus <spacibba <at> aol.com>

Date: Mon, 6 May 2024 01:31:01 UTC

Severity: normal

Found in version 30.0.50

Done: Eli Zaretskii <eliz <at> gnu.org>

To reply to this bug, email your comments to 70794 AT debbugs.gnu.org.
There is no need to reopen the bug first.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#70794; Package emacs. (Mon, 06 May 2024 01:31:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Ergus <spacibba <at> aol.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Mon, 06 May 2024 01:31:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Ergus <spacibba <at> aol.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 30.0.50; Add Rust compilation regex
Date: Mon, 06 May 2024 03:28:43 +0200

Hi:

Recently working with rust I have noticed that emacs does not recognizes
the rust/cargo error patterns.

Considering that emacs has now the rust-ts-mode, it may worth adding
the rust/cargo error patterns to compile when using that mode

In my system so far I have this:

```
(with-eval-after-load 'rust-ts-mode
  (with-eval-after-load 'compile
    (add-to-list
     'compilation-error-regexp-alist-alist
     `(cargo
       "\\(?:\\(?4:error\\)\\|\\(?5:warning\\)\\):[^\0]+?--> \\(?1:[^:]+\\):\\(?2:[[:digit:]]+\\):\\(?3:[[:digit:]]+\\)"
       1 2 3 (5)
       nil
       (5 compilation-warning-face)
       (4 compilation-error-face)))

    (add-to-list 'compilation-error-regexp-alist 'cargo)))

```

Maybe a more frequent rust user has a more general regex to
recommend. But this one works for me.

WDYT?





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#70794; Package emacs. (Sat, 11 May 2024 08:52:02 GMT) Full text and rfc822 format available.

Message #8 received at 70794 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Ergus <spacibba <at> aol.com>
Cc: 70794 <at> debbugs.gnu.org
Subject: Re: bug#70794: 30.0.50; Add Rust compilation regex
Date: Sat, 11 May 2024 11:51:04 +0300
> Date: Mon, 06 May 2024 03:28:43 +0200
> From:  Ergus via "Bug reports for GNU Emacs,
>  the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org>
> 
> Recently working with rust I have noticed that emacs does not recognizes
> the rust/cargo error patterns.
> 
> Considering that emacs has now the rust-ts-mode, it may worth adding
> the rust/cargo error patterns to compile when using that mode
> 
> In my system so far I have this:
> 
> ```
> (with-eval-after-load 'rust-ts-mode
>   (with-eval-after-load 'compile
>     (add-to-list
>      'compilation-error-regexp-alist-alist
>      `(cargo
>        "\\(?:\\(?4:error\\)\\|\\(?5:warning\\)\\):[^\0]+?--> \\(?1:[^:]+\\):\\(?2:[[:digit:]]+\\):\\(?3:[[:digit:]]+\\)"
>        1 2 3 (5)
>        nil
>        (5 compilation-warning-face)
>        (4 compilation-error-face)))
> 
>     (add-to-list 'compilation-error-regexp-alist 'cargo)))
> 
> ```
> 
> Maybe a more frequent rust user has a more general regex to
> recommend. But this one works for me.
> 
> WDYT?

Thanks, but could you please also send the examples of Rust messages,
because we need to add them to etc/compilation.txt?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#70794; Package emacs. (Wed, 15 May 2024 13:11:01 GMT) Full text and rfc822 format available.

Message #11 received at 70794 <at> debbugs.gnu.org (full text, mbox):

From: Ergus <spacibba <at> aol.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 70794 <at> debbugs.gnu.org
Subject: Re: bug#70794: 30.0.50; Add Rust compilation regex
Date: Wed, 15 May 2024 15:10:02 +0200
On Sat, May 11, 2024 at 11:51:04AM GMT, Eli Zaretskii wrote:
>> Date: Mon, 06 May 2024 03:28:43 +0200
>> From:  Ergus via "Bug reports for GNU Emacs,
>>  the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org>
>>
>> Recently working with rust I have noticed that emacs does not recognizes
>> the rust/cargo error patterns.
>>
>> Considering that emacs has now the rust-ts-mode, it may worth adding
>> the rust/cargo error patterns to compile when using that mode
>>
>> In my system so far I have this:
>>
>> ```
>> (with-eval-after-load 'rust-ts-mode
>>   (with-eval-after-load 'compile
>>     (add-to-list
>>      'compilation-error-regexp-alist-alist
>>      `(cargo
>>        "\\(?:\\(?4:error\\)\\|\\(?5:warning\\)\\):[^\0]+?--> \\(?1:[^:]+\\):\\(?2:[[:digit:]]+\\):\\(?3:[[:digit:]]+\\)"
>>        1 2 3 (5)
>>        nil
>>        (5 compilation-warning-face)
>>        (4 compilation-error-face)))
>>
>>     (add-to-list 'compilation-error-regexp-alist 'cargo)))
>>
>> ```
>>
>> Maybe a more frequent rust user has a more general regex to
>> recommend. But this one works for me.
>>
>> WDYT?
>
>Thanks, but could you please also send the examples of Rust messages,
>because we need to add them to etc/compilation.txt?

Hi Eli:

Typically they look like this:

```
error[E0425]: cannot find function `ruun` in module `broot::cli`
  --> src/main.rs:6:23
   |
6  |     match broot::cli::ruun() {
   |                       ^^^^ help: a function with a similar name exists: `run`
   |
  ::: /tmp/broot/src/cli/mod.rs:49:1
   |
49 | pub fn run() -> Result<Option<Launchable>, ProgramError> {
   | -------------------------------------------------------- similarly
   named function `run` defined here
```

or

```
error: cannot find macro `deebug` in this scope
   --> src/main.rs:5:5
    |
5   |     deebug!("env::args(): {:#?}", std::env::args().collect::<Vec<String>>());
    |     ^^^^^^ help: a macro with a similar name exists: `debug`
    |
   ::: /home/ergo/.cargo/registry/src/index.crates.io-6f17d22bba15001f/log-0.4.21/src/macros.rs:154:1
    |
154 | macro_rules! debug {
    | ------------------ similarly named macro `debug` defined here
```

```
warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`
 --> src/main.rs:3:1
  |
3 | #[feature(proc_macro_diagnostic)]
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: `#[warn(unused_attributes)]` on by default
```

Two details:

1. As you can see the [] is optional
2. The path is always relative to project's root





Reply sent to Eli Zaretskii <eliz <at> gnu.org>:
You have taken responsibility. (Sat, 18 May 2024 10:53:01 GMT) Full text and rfc822 format available.

Notification sent to Ergus <spacibba <at> aol.com>:
bug acknowledged by developer. (Sat, 18 May 2024 10:53:02 GMT) Full text and rfc822 format available.

Message #16 received at 70794-done <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Ergus <spacibba <at> aol.com>
Cc: 70794-done <at> debbugs.gnu.org
Subject: Re: bug#70794: 30.0.50; Add Rust compilation regex
Date: Sat, 18 May 2024 13:52:29 +0300
> Date: Wed, 15 May 2024 15:10:02 +0200
> From: Ergus <spacibba <at> aol.com>
> Cc: 70794 <at> debbugs.gnu.org
> 
> On Sat, May 11, 2024 at 11:51:04AM GMT, Eli Zaretskii wrote:
> >
> >Thanks, but could you please also send the examples of Rust messages,
> >because we need to add them to etc/compilation.txt?
> 
> Hi Eli:
> 
> Typically they look like this:
> 
> ```
> error[E0425]: cannot find function `ruun` in module `broot::cli`
>    --> src/main.rs:6:23
>     |
> 6  |     match broot::cli::ruun() {
>     |                       ^^^^ help: a function with a similar name exists: `run`
>     |
>    ::: /tmp/broot/src/cli/mod.rs:49:1
>     |
> 49 | pub fn run() -> Result<Option<Launchable>, ProgramError> {
>     | -------------------------------------------------------- similarly
>     named function `run` defined here
> ```
> 
> or
> 
> ```
> error: cannot find macro `deebug` in this scope
>     --> src/main.rs:5:5
>      |
> 5   |     deebug!("env::args(): {:#?}", std::env::args().collect::<Vec<String>>());
>      |     ^^^^^^ help: a macro with a similar name exists: `debug`
>      |
>     ::: /home/ergo/.cargo/registry/src/index.crates.io-6f17d22bba15001f/log-0.4.21/src/macros.rs:154:1
>      |
> 154 | macro_rules! debug {
>      | ------------------ similarly named macro `debug` defined here
> ```
> 
> ```
> warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`
>   --> src/main.rs:3:1
>    |
> 3 | #[feature(proc_macro_diagnostic)]
>    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>    |
>    = note: `#[warn(unused_attributes)]` on by default
> ```
> 
> Two details:
> 
> 1. As you can see the [] is optional
> 2. The path is always relative to project's root

Thanks, installed on master, and closing the bug.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#70794; Package emacs. (Fri, 31 May 2024 17:18:02 GMT) Full text and rfc822 format available.

Message #19 received at 70794 <at> debbugs.gnu.org (full text, mbox):

From: Mattias EngdegÄrd <mattias.engdegard <at> gmail.com>
To: Ergus <spacibba <at> aol.com>
Cc: 70794 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>
Subject: bug#70794: 30.0.50; Add Rust compilation regex
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?






This bug report was last modified 1 day ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.