[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/rust-mode 97f6445 132/486: Merge pull request #38 from Mic
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/rust-mode 97f6445 132/486: Merge pull request #38 from MicahChalmer/fix-issue-36 |
Date: |
Sat, 7 Aug 2021 09:25:04 -0400 (EDT) |
branch: elpa/rust-mode
commit 97f644577424547498ab4de5b0ec053c978cf39c
Merge: 3a0a727 fea20e7
Author: Felix S Klock II <pnkfelix@pnkfx.org>
Commit: Felix S Klock II <pnkfelix@pnkfx.org>
Merge pull request #38 from MicahChalmer/fix-issue-36
Fix emacs state corruption from incorrect "syntax-begin-function" setting
---
rust-mode-tests.el | 97 +++++++++++++++++++++++++++++++++++++++++++++++++++++-
rust-mode.el | 1 -
2 files changed, 96 insertions(+), 2 deletions(-)
diff --git a/rust-mode-tests.el b/rust-mode-tests.el
index bdc18f3..50fb8a0 100644
--- a/rust-mode-tests.el
+++ b/rust-mode-tests.el
@@ -293,7 +293,7 @@ very very very long string
;; The indentation will fail in some cases if the syntax properties are
;; not set. This only happens when font-lock fontifies the buffer.
(font-lock-fontify-buffer)
- (indent-region 1 (buffer-size)))
+ (indent-region 1 (+ 1 (buffer-size))))
indented)))
@@ -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 5e34201 061/486: Add defun motions for rust-mode., (continued)
- [nongnu] elpa/rust-mode 5e34201 061/486: Add defun motions for rust-mode., ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 0e58eb3 076/486: emacs: Add 'box' to keywords, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 226102c 086/486: emacs: Add shebang to test script, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 186583d 096/486: Mark _ as a word constituent to avoid highlighting parts of identifiers as keywords, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 04e4b49 103/486: Add .travis.yml, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode ec81a95 114/486: Merge pull request #22 from nikomatsakis/align-method-chain, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 351cc91 112/486: Merge pull request #16 from MicahChalmer/add-travis, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode b3f87b9 122/486: Make the test driver script a little more informative., ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 19bc0e9 121/486: Merge pull request #30 from MicahChalmer/emacs23-fixup, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode bddc933 124/486: Fix typo in comment, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 97f6445 132/486: Merge pull request #38 from MicahChalmer/fix-issue-36,
ELPA Syncer <=
- [nongnu] elpa/rust-mode 42730b1 144/486: Merge pull request #49 from huonw/playpen, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 249e3ce 134/486: Merge pull request #40 from MicahChalmer/fix-comment-typos, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 31ceb60 135/486: Indent inside strings after ending backslash, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 22c8cfa 138/486: Merge pull request #43 from MicahChalmer/indent-backslash-strings, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode ce976b9 145/486: Fix "-> Type" on a single line indentation, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode f2f4d67 158/486: Merge pull request #59 from lunaryorn/fix-byte-compiler-warnings, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode ddf45ed 146/486: Use (goto-char (point-max)) instead of (end-of-buffer) to silence warning., ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 0077bbf 160/486: Fix package.el URL, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 86db9bd 166/486: Merge pull request #65 from tromey/blink-matching-paren, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 53c558c 175/486: Factor out rust-conditional-re-search-forward, ELPA Syncer, 2021/08/07