emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/rust-mode 6e9db46 331/486: Merge pull request #230 from tr


From: ELPA Syncer
Subject: [nongnu] elpa/rust-mode 6e9db46 331/486: Merge pull request #230 from tromey/fix-indentation-bug
Date: Sat, 7 Aug 2021 09:25:46 -0400 (EDT)

branch: elpa/rust-mode
commit 6e9db4665036ca6f0fe8eecf55cd243eaebccc62
Merge: e48a650 38f7d89
Author: Tom Tromey <tom@tromey.com>
Commit: GitHub <noreply@github.com>

    Merge pull request #230 from tromey/fix-indentation-bug
    
    Fix recognition of "<" as operator in some context
---
 rust-mode-tests.el | 11 +++++++++++
 rust-mode.el       |  3 +++
 2 files changed, 14 insertions(+)

diff --git a/rust-mode-tests.el b/rust-mode-tests.el
index 7335334..aab82df 100644
--- a/rust-mode-tests.el
+++ b/rust-mode-tests.el
@@ -2034,6 +2034,17 @@ fn main() {
     baz();
 }"))
 
+;; Regression test for #212.
+(ert-deftest indent-left-shift ()
+  (test-indent "
+fn main() {
+    let a = [[0u32, 0u32]; 1];
+    let i = 0;
+    let x = a[i][(1 < i)];
+    let x = a[i][(1 << i)];
+}
+"))
+
 (defun rust-test-matching-parens (content pairs &optional nonparen-positions)
   "Assert that in rust-mode, given a buffer with the given `content',
   emacs's paren matching will find all of the pairs of positions
diff --git a/rust-mode.el b/rust-mode.el
index 1c0921b..ed5b5ed 100644
--- a/rust-mode.el
+++ b/rust-mode.el
@@ -812,6 +812,9 @@ match data if found. Returns nil if not within a Rust 
string."
        ;; it to be an expression.
        ((and (equal token 'open-brace) (rust-looking-back-macro)) t)
        
+       ;; In a brace context a "]" introduces an expression.
+       ((and (eq token 'open-brace) (rust-looking-back-str "]")))
+
        ;; An identifier is right after an ending paren, bracket, angle bracket
        ;; or curly brace.  It's a type if the last sexp was a type.
        ((and (equal token 'ident) (equal 5 (rust-syntax-class-before-point)))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]