Skip to content

Add compilation regexp to match ‘dbg!’ output #569

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions rust-compile.el
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ See `compilation-error-regexp-alist' for help on their format.")
"Specifications for matching panics in cargo test invocations.
See `compilation-error-regexp-alist' for help on their format.")

(defvar rustc-dbg!-compilation-regexps
(let ((re (concat "\\[" rustc-compilation-location "\\]")))
(cons re '(2 3 4 0 1)))
"Specifications for matching dbg! output.
See `compilation-error-regexp-alist' for help on their format.")

(defun rustc-scroll-down-after-next-error ()
"In the new style error messages, the regular expression
matches on the file name (which appears after `-->`), but the
Expand Down Expand Up @@ -85,6 +91,9 @@ the compilation window until the top of the error is visible."
(cons 'rustc-panics rustc-panics-compilation-regexps))
(add-to-list 'compilation-error-regexp-alist 'rustc-panics)
(add-to-list 'compilation-error-regexp-alist 'cargo)
(add-to-list 'compilation-error-regexp-alist-alist
(cons 'rust-dbg! rustc-dbg!-compilation-regexps))
(add-to-list 'compilation-error-regexp-alist 'rust-dbg!)
(add-hook 'next-error-hook #'rustc-scroll-down-after-next-error)))

;;; _
Expand Down
7 changes: 5 additions & 2 deletions rust-mode-tests.el
Original file line number Diff line number Diff line change
Expand Up @@ -3693,6 +3693,7 @@ let b = 1;"
(insert "note: `ZZZ` could also refer to the constant imported here -> b\n --> file4.rs:12:34\n\n")
(insert " ::: file5.rs:12:34\n\n")
(insert "thread 'main' panicked at src/file7.rs:12:34:\n\n")
(insert "[src/file8.rs:159:5] symbol_value(SOME_VAR) = Some(\n\n")
;; should not match
(insert "werror found a -> b\n --> no_match.rs:12:34\n\n")
(insert "error[E0061]: this function takes 1 parameter but 2 parameters were supplied\n --> file6.rs:132:34
Expand All @@ -3712,12 +3713,14 @@ let b = 1;"
(("file5.rs" "12" "34" compilation-info "file5.rs:12:34"))
((like-previous-one "82" back-to-indentation compilation-info "82")
(like-previous-one "132" back-to-indentation compilation-info "132"))
(("src/file7.rs" "12" "34" nil "src/file7.rs:12:34")))
(("src/file7.rs" "12" "34" nil "src/file7.rs:12:34"))
(("src/file8.rs" "159" "5" compilation-info "src/file8.rs:159:5")))
(mapcar #'rust-collect-matches
(list rustc-compilation-regexps
rustc-colon-compilation-regexps
rustc-refs-compilation-regexps
rustc-panics-compilation-regexps))))))
rustc-panics-compilation-regexps
rustc-dbg!-compilation-regexps))))))

;; If electric-pair-mode is available, load it and run the tests that use it. If not,
;; no error--the tests will be skipped.
Expand Down