Skip to content

Commit dd231ed

Browse files
committed
Avoid signaling "Beginning of buffer" in rust-lookng-back-macro
Also save some work if we don't have at least two characters behind us in the buffer, we know we can't be looking at a macro then. The signal occurs when one tries 'racer-describe' when positioned over "String", which eventually ends up calling (with-temp-buffer (insert "<Target=str>") (delay-mode-hooks (rust-mode)) (font-lock-ensure)) This simpler block will also trigger the error (with-temp-buffer (insert "<>") (rust-mode) (font-lock-ensure)) (font-lock-ensure) call ends up calling (rust-looking-back-macro).
1 parent 54a9c3d commit dd231ed

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

rust-mode.el

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ Like `looking-back' but for fixed strings rather than regexps (so that it's not
8080

8181
(defun rust-looking-back-macro ()
8282
"Non-nil if looking back at an ident followed by a !"
83-
(save-excursion (backward-char) (and (= ?! (char-after)) (rust-looking-back-ident))))
83+
(if (> (point) 2)
84+
(save-excursion (backward-char) (and (= ?! (char-after)) (rust-looking-back-ident)))))
8485

8586
;; Syntax definitions and helpers
8687
(defvar rust-mode-syntax-table
@@ -1594,7 +1595,7 @@ This is written mainly to be used as `end-of-defun-function' for Rust."
15941595
(when rust-format-on-save
15951596
(unless (executable-find rust-rustfmt-bin)
15961597
(error "Could not locate executable \"%s\"" rust-rustfmt-bin))))
1597-
1598+
15981599
(defvar rustc-compilation-regexps
15991600
(let ((file "\\([^\n]+\\)")
16001601
(start-line "\\([0-9]+\\)")

0 commit comments

Comments
 (0)