[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/rust-mode 38f7d89 330/486: Fix recognition of "<" as opera
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/rust-mode 38f7d89 330/486: Fix recognition of "<" as operator in some context |
Date: |
Sat, 7 Aug 2021 09:25:46 -0400 (EDT) |
branch: elpa/rust-mode
commit 38f7d891e62ce8bb8ff60a8126fb4ce06af5b6b5
Author: Tom Tromey <tom@tromey.com>
Commit: Tom Tromey <tom@tromey.com>
Fix recognition of "<" as operator in some context
rust-mode identifies the "<<" as open angle brackets in
let x = a[i][(1 << i)];
This patch fixes the problem by changing rust-is-in-expression-context
to treat "]" as starting an expression in brace context.
Fixes #212
---
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)))
- [nongnu] elpa/rust-mode 12cb169 375/486: Merge pull request #284 from riscy/master, (continued)
- [nongnu] elpa/rust-mode 12cb169 375/486: Merge pull request #284 from riscy/master, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 8452093 278/486: put remaining defcustoms into the rust-mode group, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 8f1297a 281/486: Merge pull request #187 from tspiteri/format-other-buffers, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 5c68caf 282/486: Merge pull request #175 from mrBliss/imenu-unsafe, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode f269c5e 292/486: fix syntax of "<" appearing after "?", ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 491ae0e 301/486: Remove unnecessary debugging message, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 60a1f36 310/486: Merge pull request #216 from Aankhen/set-compile-command, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 128601b 317/486: Improve content of `test-project/Cargo.toml'., ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 30a9d39 322/486: Merge pull request #221 from Wilfred/highlight_union_contextual_keyword, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 6093d38 327/486: Add syntax coloring for type-inferred constants and variables, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 38f7d89 330/486: Fix recognition of "<" as operator in some context,
ELPA Syncer <=
- [nongnu] elpa/rust-mode 0ded5ea 332/486: Add support for u128 and i128 types, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode f57a8eb 333/486: Merge pull request #233 from shanavas786/add-128, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 6b71c0a 348/486: fix rust--format-call, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode a90730f 349/486: don't set-window-start for selected window, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 27911c8 351/486: Merge pull request #251 from brotzeit/rust-format-buffer, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 216faf2 353/486: Do not indent where clause by default (follow standard) #257, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode e201404 367/486: Fix font-locking of "let ref", ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 8d32dc6 370/486: Add keywords `async` and `try`, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 54a9c3d 380/486: Merge pull request #296 from dekellum/indent-return-type-defcustom, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode ce7a27f 381/486: Add compilation mode warning face, ELPA Syncer, 2021/08/07