]> git.eshelyaron.com Git - emacs.git/commitdiff
Support Rust compiler messages in compile mode (bug#70794).
authorVincenzo Pupillo <v.pupillo@gmail.com>
Mon, 19 May 2025 20:31:41 +0000 (22:31 +0200)
committerEshel Yaron <me@eshelyaron.com>
Tue, 27 May 2025 14:30:03 +0000 (16:30 +0200)
* etc/compilation.txt: Add examples of Rust compiler error, warning and
note messages.
* lisp/progmodes/compile.el
(compilation-error-regexp-alist-alist): Add Rust regexps for error,
warning and note messages.
* test/lisp/progmodes/compile-tests.el
(compile-tests--test-regexps-data): Add new test cases.
(compile-test-error-regexps): Increase expected errors.

(cherry picked from commit 676f12c65f751f14093c446a7b637a365de253a5)

etc/compilation.txt
lisp/progmodes/compile.el
test/lisp/progmodes/compile-tests.el

index 67c7000ae094cef8f3444c033f9b3f314dac4b8a..39d9c3a923c4f1728a6337ee1ee45f5cfd097706 100644 (file)
@@ -487,6 +487,17 @@ symbol: php
 Parse error: parse error, unexpected $ in main.php on line 59
 Fatal error: Call to undefined function: mysql_pconnect() in db.inc on line 66
 
+* Rust
+
+symbol: rust
+
+error[E0277]: `Foo` is not an iterator
+  --> src/main.rs:4:16
+warning: borrow of packed field is unsafe and requires unsafe function or block (error E0133)
+  --> lint_example.rs:11:13
+note: required by a bound in `Trait`
+  --> src/auxiliary/trait-debuginfo.rs:23:18
+
 * Ruby
 
 symbol: ruby
index 7c3bde6a188577bce0169f4af9be19353a90caaa..5ab8a98005d0f60f2d5934c844f418744a743035 100644 (file)
@@ -588,6 +588,19 @@ during global destruction\\.$\\)" 1 2)
      "\\(?:Parse\\|Fatal\\) error: \\(.*\\) in \\(.*\\) on line \\([0-9]+\\)"
      2 3 nil nil)
 
+    (rust
+     ,(rx bol (or (group-n 1 "error") (group-n 2 "warning") (group-n 3 "note"))
+          (? "[" (+ (in "A-Z" "0-9")) "]") ":" (* nonl)
+          "\n" (+ " ") "-->"
+          " " (group-n 4 (+ nonl))        ; file
+          ":" (group-n 5 (+ (in "0-9")))  ; line
+          ":" (group-n 6 (+ (in "0-9")))) ; column
+     4 5 6 (2 . 3)
+     nil
+     (1 compilation-error-face)
+     (2 compilation-warning-face)
+     (3 compilation-info-face))
+
     (rxp
      "^\\(?:Error\\|Warnin\\(g\\)\\):.*\n.* line \\([0-9]+\\) char\
  \\([0-9]+\\) of file://\\(.+\\)"
index b12e5d0b2d43b1baba11171754830bd8de75588e..38d5d2bb43b0af88d06d08a152283e0aa3e86ebb 100644 (file)
      1 nil 59 "main.php")
     (php "Fatal error: Call to undefined function: mysql_pconnect() in db.inc on line 66"
      1 nil 66 "db.inc")
+    ;; rust
+    (rust
+     "error[E0277]: `Foo` is not an iterator\n --> src/main.rs:4:16"
+     1 16 4 "src/main.rs")
+    (rust "warning: borrow of packed field is unsafe and requires unsafe function or block (error E0133)\n  --> lint_example.rs:11:13"
+           1 13 11 "lint_example.rs")
+    (rust
+     "note: required by a bound in `Trait`\n  --> src/auxiliary/trait-debuginfo.rs:23:18"
+     1 18 23 "src/auxiliary/trait-debuginfo.rs")
     ;; ruby (uses gnu)
     (gnu "plain-exception.rb:7:in `fun': unhandled exception"
      1 nil 7 "plain-exception.rb")
@@ -538,9 +547,9 @@ The test data is in `compile-tests--test-regexps-data'."
                    1 15 5 "alpha.c")))
         (compile--test-error-line test))
 
-      (should (eq compilation-num-errors-found 107))
-      (should (eq compilation-num-warnings-found 36))
-      (should (eq compilation-num-infos-found 35)))))
+      (should (eq compilation-num-errors-found 108))
+      (should (eq compilation-num-warnings-found 37))
+      (should (eq compilation-num-infos-found 36)))))
 
 (ert-deftest compile-test-grep-regexps ()
   "Test the `grep-regexp-alist' regexps.