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: Mattias Engdegård <mattias.engdegard <at> gmail.com>

Full log


View this message in rfc822 format

From: Vincenzo Pupillo <v.pupillo <at> gmail.com>
To: Mattias Engdegård <mattias.engdegard <at> gmail.com>
Cc: dev <at> rjt.dev, spacibba <at> aol.com, 70794 <at> debbugs.gnu.org, stefankangas <at> gmail.com, eliz <at> gnu.org
Subject: bug#70794: 30.0.50; Add Rust compilation regex
Date: Sat, 17 May 2025 22:37:37 +0200
Ciao Mattias,

In data giovedì 15 maggio 2025 20:42:42 Ora legale dell’Europa centrale, 
Mattias Engdegård ha scritto:
> 28 apr. 2025 kl. 22.22 skrev Vincenzo Pupillo <v.pupillo <at> gmail.com>:
> > 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.
No, the spaces before the arrow vary according to the line number of the 
error. The arrow is aligned with the vertical bar separating the line number 
from the error description.
This is an example (rustc version 1.86):

--8<---------------cut here---------------start------------->8---
warning: unknown lint: `multiple_supertrait_upcastable`
    --> test.rs:1024:9
     |
1024 | #[allow(multiple_supertrait_upcastable)]
     |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     |
     = note: the `multiple_supertrait_upcastable` lint is unstable
     = note: `#[warn(unknown_lints)]` on by default

error[E0152]: found duplicate lang item `sized`
   --> test.rs:148:1
    |
148 | / pub trait Sized {
149 | |     // Empty.
150 | | }
    | |_^
    |
    = note: the lang item is first defined in crate `core` (which `std` 
depends on)
    = note: first definition in `core` loaded from /usr/lib/rustlib/x86_64-
unknown-linux-gnu/lib/libcore-1efaafb24524a678.rlib
    = note: second definition in the local crate (`test`)
--8<---------------cut here---------------end--------------->8---

> 
> 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
> 

Thank you!
I made a small change taking into account what I read in the source code of 
the rust compiler. The number of spaces before the arrow should be between 1 
and 6, so I made a small change:

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

WDYT?

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

Ok.

Thanks.

Vincenzo








This bug report was last modified 23 days ago.

Previous Next


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