summaryrefslogtreecommitdiff
path: root/rust-mode.el
diff options
context:
space:
mode:
Diffstat (limited to 'rust-mode.el')
-rw-r--r--rust-mode.el17
1 files changed, 13 insertions, 4 deletions
diff --git a/rust-mode.el b/rust-mode.el
index 8385a7e..c2102c9 100644
--- a/rust-mode.el
+++ b/rust-mode.el
@@ -1555,7 +1555,8 @@ This is written mainly to be used as `end-of-defun-function' for Rust."
(setq-local parse-sexp-lookup-properties t)
(setq-local electric-pair-inhibit-predicate 'rust-electric-pair-inhibit-predicate-wrap)
- (add-hook 'before-save-hook 'rust--before-save-hook nil t)
+ (add-hook 'before-save-hook 'rust-before-save-hook nil t)
+ (add-hook 'after-save-hook 'rust-after-save-hook nil t)
(setq-local rust-buffer-project nil)
@@ -1571,9 +1572,17 @@ This is written mainly to be used as `end-of-defun-function' for Rust."
(require 'rust-mode)
(rust-mode))
-(defun rust--before-save-hook ()
- (when rust-format-on-save (rust-format-buffer)))
-
+(defun rust-before-save-hook ()
+ (when rust-format-on-save
+ (condition-case nil
+ (rust-format-buffer)
+ (error nil))))
+
+(defun rust-after-save-hook ()
+ (when rust-format-on-save
+ (unless (executable-find rust-rustfmt-bin)
+ (error "Could not locate executable \"%s\"" rust-rustfmt-bin))))
+
(defvar rustc-compilation-regexps
(let ((file "\\([^\n]+\\)")
(start-line "\\([0-9]+\\)")