[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/rust-mode 1587839 268/486: Merge pull request #169 from mr
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/rust-mode 1587839 268/486: Merge pull request #169 from mrBliss/fix-168 |
Date: |
Sat, 7 Aug 2021 09:25:33 -0400 (EDT) |
branch: elpa/rust-mode
commit 1587839ba493b5ab98fb8415338172a9a22f224b
Merge: 5cfb919 bec3d0c
Author: Niko Matsakis <niko@alum.mit.edu>
Commit: GitHub <noreply@github.com>
Merge pull request #169 from mrBliss/fix-168
Fix #168: use while in rust-rewind-irrelevant
---
rust-mode-tests.el | 17 +++++++++++++++++
rust-mode.el | 20 +++++++++++++-------
2 files changed, 30 insertions(+), 7 deletions(-)
diff --git a/rust-mode-tests.el b/rust-mode-tests.el
index 3c3ba03..35a1cbd 100644
--- a/rust-mode-tests.el
+++ b/rust-mode-tests.el
@@ -1162,6 +1162,23 @@ All positions are position symbols found in
`rust-test-positions-alist'."
'nonblank-line-indented-already-middle-target
#'indent-for-tab-command))
+(ert-deftest no-stack-overflow-in-rust-rewind-irrelevant ()
+ (with-temp-buffer
+ (rust-mode)
+ (insert "fn main() {\n let x = 1;")
+ ;; Insert 150 separate comments on the same line
+ (dotimes (i 150)
+ (insert "/* foo */ "))
+ ;; Rewinding from the last commment to the end of the let needs at least
+ ;; 150 iterations, but if we limit the stack depth to 100 (this appears to
+ ;; be some minimum), a recursive function would overflow, throwing an
+ ;; error.
+ (let ((max-lisp-eval-depth 100))
+ (rust-rewind-irrelevant)
+ ;; Only a non-stack overflowing function would make it this far. Also
+ ;; check that we rewound till after the ;
+ (should (= (char-before) ?\;)))))
+
(defun rust-test-fontify-string (str)
(with-temp-buffer
(rust-mode)
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)
- [nongnu] elpa/rust-mode a33b684 207/486: Fix #103: comment indentation after struct members, (continued)
- [nongnu] elpa/rust-mode a33b684 207/486: Fix #103: comment indentation after struct members, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 339afba 206/486: Highlight the unsafe keyword, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode fa5b38f 218/486: Merge pull request #117 from TheBB/fix-closing-delim, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 1ceac8b 212/486: Re-fontify buffer after it is reverted, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 01db4cb 225/486: Fix font-locking for Unicode escapes in character literals., ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode b874bbe 213/486: Merge pull request #113 from MicahChalmer/fix-issue-104, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 2cd3cf9 216/486: Merge pull request #116 from Wilfred/type_annotation_highlighting, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 3517321 230/486: Merge pull request #129 from MicahChalmer/fix-issue-127, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 8400638 241/486: update README.md and Package-Requires to require emacs 24, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode c3feac1 243/486: Fill regular block comments correctly too, in addition to rustdoc comments, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 1587839 268/486: Merge pull request #169 from mrBliss/fix-168,
ELPA Syncer <=
- [nongnu] elpa/rust-mode 664c7b0 277/486: improve position recovery in rust-format-buffer, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 46e7fc0 285/486: fix PR link in README, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 35298ed 288/486: Don't use "&optional &rest", ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 3301c70 047/486: Align field names in struct expressions with fields on same line as the opening curly brace, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode fe55b71 046/486: Multiline comments with leading *s line up the *s, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode af2aba9 049/486: Indent correctly after opening square bracket, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode b83aabf 054/486: Add ERT tests, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 38dab12 063/486: Fix rust-align-to-expr-after-brace, closes #11239., ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 7625c5c 058/486: Add 'continue' keyword to emacs, vim, gedit, kate, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode d82b5a7 062/486: Add "proc" as keyword to emacs mode, ELPA Syncer, 2021/08/07