emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/rust-mode a789a25 266/486: Fix #168: use while in rust-rew


From: ELPA Syncer
Subject: [nongnu] elpa/rust-mode a789a25 266/486: Fix #168: use while in rust-rewind-irrelevant
Date: Sat, 7 Aug 2021 09:25:33 -0400 (EDT)

branch: elpa/rust-mode
commit a789a257c703d1e0041b6b193a41429124f90b44
Author: mrBliss <dewinant@gmail.com>
Commit: mrBliss <dewinant@gmail.com>

    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)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]