File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -1162,6 +1162,23 @@ All positions are position symbols found in `rust-test-positions-alist'."
1162
1162
'nonblank-line-indented-already-middle-target
1163
1163
#'indent-for-tab-command ))
1164
1164
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
+
1165
1182
(defun rust-test-fontify-string (str )
1166
1183
(with-temp-buffer
1167
1184
(rust-mode )
You can’t perform that action at this time.
0 commit comments