branch: elpa/rust-mode
commit a789a257c703d1e0041b6b193a41429124f90b44
Author: mrBliss <[email protected]>
Commit: mrBliss <[email protected]>
Fix #168: use while in rust-rewind-irrelevant
Rewrite the recursive function `rust-rewind-irrelevant`, which causes a
stack overflow in #168, using a `while` loop.
---
rust-mode.el | 20 +++++++++++++-------
1 file changed, 13 insertions(+), 7 deletions(-)
diff --git a/rust-mode.el b/rust-mode.el
index 4867e77..2c97433 100644
--- a/rust-mode.el
+++ b/rust-mode.el
@@ -201,14 +201,20 @@ function or trait. When nil, where will be aligned with
fn or trait."
(defun rust-paren-level () (nth 0 (syntax-ppss)))
(defun rust-in-str-or-cmnt () (nth 8 (syntax-ppss)))
(defun rust-rewind-past-str-cmnt () (goto-char (nth 8 (syntax-ppss))))
+
(defun rust-rewind-irrelevant ()
- (let ((starting (point)))
- (skip-chars-backward "[:space:]\n")
- (if (rust-looking-back-str "*/") (backward-char))
- (if (rust-in-str-or-cmnt)
- (rust-rewind-past-str-cmnt))
- (if (/= starting (point))
- (rust-rewind-irrelevant))))
+ (let ((continue t))
+ (while continue
+ (let ((starting (point)))
+ (skip-chars-backward "[:space:]\n")
+ (when (rust-looking-back-str "*/")
+ (backward-char))
+ (when (rust-in-str-or-cmnt)
+ (rust-rewind-past-str-cmnt))
+ ;; Rewind until the point no longer moves
+ (setq continue (/= starting (point)))))))
+
+
(defun rust-in-macro ()
(save-excursion
(when (> (rust-paren-level) 0)