Skip to content

Commit 6e9db46

Browse files
authored
Merge pull request #230 from tromey/fix-indentation-bug
Fix recognition of "<" as operator in some context
2 parents e48a650 + 38f7d89 commit 6e9db46

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

rust-mode-tests.el

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2034,6 +2034,17 @@ fn main() {
20342034
baz();
20352035
}"))
20362036

2037+
;; Regression test for #212.
2038+
(ert-deftest indent-left-shift ()
2039+
(test-indent "
2040+
fn main() {
2041+
let a = [[0u32, 0u32]; 1];
2042+
let i = 0;
2043+
let x = a[i][(1 < i)];
2044+
let x = a[i][(1 << i)];
2045+
}
2046+
"))
2047+
20372048
(defun rust-test-matching-parens (content pairs &optional nonparen-positions)
20382049
"Assert that in rust-mode, given a buffer with the given `content',
20392050
emacs's paren matching will find all of the pairs of positions

rust-mode.el

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -812,6 +812,9 @@ match data if found. Returns nil if not within a Rust string."
812812
;; it to be an expression.
813813
((and (equal token 'open-brace) (rust-looking-back-macro)) t)
814814

815+
;; In a brace context a "]" introduces an expression.
816+
((and (eq token 'open-brace) (rust-looking-back-str "]")))
817+
815818
;; An identifier is right after an ending paren, bracket, angle bracket
816819
;; or curly brace. It's a type if the last sexp was a type.
817820
((and (equal token 'ident) (equal 5 (rust-syntax-class-before-point)))

0 commit comments

Comments
 (0)