Skip to content

Commit bec3d0c

Browse files
committed
Test #169
Before applying #169 the new test fails with a stack overflow, with #169 it passes.
1 parent a789a25 commit bec3d0c

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

rust-mode-tests.el

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1162,6 +1162,23 @@ All positions are position symbols found in `rust-test-positions-alist'."
11621162
'nonblank-line-indented-already-middle-target
11631163
#'indent-for-tab-command))
11641164

1165+
(ert-deftest no-stack-overflow-in-rust-rewind-irrelevant ()
1166+
(with-temp-buffer
1167+
(rust-mode)
1168+
(insert "fn main() {\n let x = 1;")
1169+
;; Insert 150 separate comments on the same line
1170+
(dotimes (i 150)
1171+
(insert "/* foo */ "))
1172+
;; Rewinding from the last commment to the end of the let needs at least
1173+
;; 150 iterations, but if we limit the stack depth to 100 (this appears to
1174+
;; be some minimum), a recursive function would overflow, throwing an
1175+
;; error.
1176+
(let ((max-lisp-eval-depth 100))
1177+
(rust-rewind-irrelevant)
1178+
;; Only a non-stack overflowing function would make it this far. Also
1179+
;; check that we rewound till after the ;
1180+
(should (= (char-before) ?\;)))))
1181+
11651182
(defun rust-test-fontify-string (str)
11661183
(with-temp-buffer
11671184
(rust-mode)

0 commit comments

Comments
 (0)