Function: rust-ts-flymake

rust-ts-flymake is a byte-compiled function defined in rust-ts-mode.el.gz.

Signature

(rust-ts-flymake REPORT-FN &rest ARGS)

Documentation

Rust backend for Flymake.

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/rust-ts-mode.el.gz
(defun rust-ts-flymake (report-fn &rest _args)
  "Rust backend for Flymake."
  (unless (executable-find (car rust-ts-flymake-command))
    (error "Cannot find the rust flymake program: %s" (car rust-ts-flymake-command)))

  (rust-ts-flymake--helper
   "rust-ts-flymake"
   rust-ts-flymake-command
   (lambda (_proc source)
     (goto-char (point-min))
     (cl-loop
      while (search-forward-regexp
             (concat
              "^\\(\\(?:warning\\|error\\|help\\).*\\)\n +--> [^:]+:"
              "\\([0-9]+\\):\\([0-9]+\\)\\(\\(?:\n[^\n]+\\)*\\)\n\n")
             nil t)
      for msg1 = (match-string 1)
      for msg2 = (match-string 4)
      for (beg . end) = (flymake-diag-region
                         source
                         (string-to-number (match-string 2))
                         (string-to-number (match-string 3)))
      for type = (if (string-match "^warning" msg1)
                     :warning
                   :error)
      collect (flymake-make-diagnostic source
                                       beg
                                       end
                                       type
                                       (concat msg1 msg2))
      into diags
      finally (funcall report-fn diags)))))