[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/rust-mode c7413e6 130/486: Don't set syntax-begin-function
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/rust-mode c7413e6 130/486: Don't set syntax-begin-function |
Date: |
Sat, 7 Aug 2021 09:25:04 -0400 (EDT) |
branch: elpa/rust-mode
commit c7413e6b4422e6dc5a7e84d329121205b4b537ac
Author: Micah Chalmer <micah@micahchalmer.net>
Commit: Micah Chalmer <micah@micahchalmer.net>
Don't set syntax-begin-function
---
rust-mode-tests.el | 95 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
rust-mode.el | 1 -
2 files changed, 95 insertions(+), 1 deletion(-)
diff --git a/rust-mode-tests.el b/rust-mode-tests.el
index bdc18f3..0bdf680 100644
--- a/rust-mode-tests.el
+++ b/rust-mode-tests.el
@@ -1110,3 +1110,98 @@ fn main() { // comment here should not push next line out
}
"
)))
+
+(ert-deftest test-for-issue-36-syntax-corrupted-state ()
+ "This is a test for a issue #36, which involved emacs's
+internal state getting corrupted when actions were done in a
+specific sequence. The test seems arbitrary, and is, but it was
+not clear how to narrow it down further.
+
+The cause of the bug was code that used to set
+`syntax-begin-function' to `beginning-of-defun', which doesn't
+actually fulfill the expectations--`syntax-begin-function' is
+supposed to back out of all parens, but `beginning-of-defun'
+could leave it inside parens if a fn appears inside them.
+
+Having said that, as I write this I don't understand fully what
+internal state was corruped and how. There wasn't an obvious
+pattern to what did and did not trip it."
+
+ ;; When bug #36 was present, the following test would pass, but running it
+ ;; caused some unknown emacs state to be corrupted such that the following
+ ;; test failed. Both the "blank_line" and "indented_closing_brace" functions
+ (with-temp-buffer
+ (rust-mode)
+ (insert "fn blank_line(arg:int) -> bool {
+
+}
+
+fn indenting_closing_brace() {
+ if(true) {
+}
+}
+
+fn indented_already() {
+ \n // The previous line already has its spaces
+}
+")
+
+ (goto-line 11)
+ (move-to-column 0)
+ (indent-for-tab-command)
+ (should (equal (current-column) 4))
+ )
+
+ ;; This is the test that would fail only after running the previous one. The
+ ;; code is extracted from src/libstd/collections/table.rs in the rust tree.
+ ;; It was not clear how to reduce it further--removing various bits of it
+ ;; would make it no longer fail. In particular, changing only the comment at
+ ;; the top of the "next" function was sufficient to make it no longer fail.
+ (test-indent
+ "
+impl Foo for Bar {
+
+ /// Modifies the bucket pointer in place to make it point to the next slot.
+ pub fn next(&mut self) {
+ // Branchless bucket
+ // As we reach the end of the table...
+ // We take the current idx: 0111111b
+ // Xor it by its increment: ^ 1000000b
+ // ------------
+ // 1111111b
+ // Then AND with the capacity: & 1000000b
+ // ------------
+ // to get the backwards offset: 1000000b
+ let maybe_wraparound_dist = (self.idx ^ (self.idx + 1)) &
self.table.capacity();
+ // Finally, we obtain the offset 1 or the offset -cap + 1.
+ let dist = 1 - (maybe_wraparound_dist as isize);
+
+ self.idx += 1;
+
+ unsafe {
+ self.raw = self.raw.offset(dist);
+ }
+ }
+
+ /// Reads a bucket at a given index, returning an enum indicating whether
+ /// the appropriate types to call most of the other functions in
+ /// this module.
+ pub fn peek(self) {
+ match foo {
+ EMPTY_BUCKET =>
+ Empty(EmptyBucket {
+ raw: self.raw,
+ idx: self.idx,
+ table: self.table
+ }),
+ _ =>
+ Full(FullBucket {
+ raw: self.raw,
+ idx: self.idx,
+ table: self.table
+ })
+ }
+ }
+}
+"
+ ))
diff --git a/rust-mode.el b/rust-mode.el
index 29bb820..53d2e5e 100644
--- a/rust-mode.el
+++ b/rust-mode.el
@@ -661,7 +661,6 @@ This is written mainly to be used as
`end-of-defun-function' for Rust."
(setq-local beginning-of-defun-function 'rust-beginning-of-defun)
(setq-local end-of-defun-function 'rust-end-of-defun)
(setq-local parse-sexp-lookup-properties t)
- (setq-local syntax-begin-function 'beginning-of-defun)
(add-hook 'post-self-insert-hook 'rust-match-angle-bracket-hook))
;;;###autoload
- [nongnu] elpa/rust-mode 8a69f69 104/486: Use old code style for emacs 23 compat, (continued)
- [nongnu] elpa/rust-mode 8a69f69 104/486: Use old code style for emacs 23 compat, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 9e83b30 110/486: Merge pull request #21 from pnkfelix/tests-allow-override-of-which-emacs, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 55e7483 113/486: Add a hook so that we briefly highlight the matching `<` when `>` is typed., ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 439da40 115/486: disable emacs23 testing on travis., ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode d2c6d6c 116/486: Merge pull request #26 from pnkfelix/disable-emacs23-testing, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 8c9ea88 127/486: Fix raw string bugs, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode a653c6b 123/486: Highlight raw strings correctly, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode f3e8f20 119/486: Re-enable emacs23 in Travis, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 5b73df1 133/486: Fix typo/missing lines in comment in test, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 3a0a727 129/486: Merge pull request #35 from MicahChalmer/fix-raw-string-bugs, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode c7413e6 130/486: Don't set syntax-begin-function,
ELPA Syncer <=
- [nongnu] elpa/rust-mode b15b0eb 140/486: Merge pull request #45 from MicahChalmer/backslash-and-double-quote-char-literals, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 52febe9 137/486: Add a few more tests for indents inside strings, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 766bd82 139/486: Parse '\\' and '\"' as char literals, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode d6b1739 136/486: Fix spurious errors in emacs 23, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 3995d33 152/486: Add regression test for PR #52., ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode f2d709e 141/486: Make fill-region work correctly, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 8a8bd58 159/486: Merge pull request #58 from lunaryorn/patch-1, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 2f0c84f 150/486: rust-align-to-method-chain: Jump over symbols, not words, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 2e800ee 151/486: workaround emacs 23 issues., ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 2be934c 147/486: Merge pull request #55 from kriben/master, ELPA Syncer, 2021/08/07